Guest viewing is limited
  • Please if you have anything to share with us dont fall back, upload your resources, Questions and solutions for others to benefit too.

Logistics company website source code

Full source code for shipping company,get free just download it. Feedback is best payment for us :cool: #Developer Bless
emails system is incomplete,it doesnt work.
Update your form in contact.html
Replace your <form> </form> with
HTML:
<form action="send-mail.php" method="POST">
    <div class="row g-3">
        <div class="col-md-6">
            <div class="form-floating">
                <input type="text" class="form-control" id="name" name="name" placeholder="Your Name" required>
                <label for="name">Your Name</label>
            </div>
        </div>
        <div class="col-md-6">
            <div class="form-floating">
                <input type="email" class="form-control" id="email" name="email" placeholder="Your Email" required>
                <label for="email">Your Email</label>
            </div>
        </div>
        <div class="col-12">
            <div class="form-floating">
                <input type="text" class="form-control" id="subject" name="subject" placeholder="Subject" required>
                <label for="subject">Subject</label>
            </div>
        </div>
        <div class="col-12">
            <div class="form-floating">
                <textarea class="form-control" placeholder="Leave a message here" id="message" name="message" style="height: 100px" required></textarea>
                <label for="message">Message</label>
            </div>
        </div>
        <div class="col-12">
            <button class="btn btn-primary w-100 py-3" type="submit">Send Message</button>
        </div>
    </div>
</form>

Also before closing the </body>
Add this js code for functions
JavaScript:
<script>
$("#contactForm").on("submit", function(e) {
    e.preventDefault();
    $("#formStatus").html("<div class='alert alert-info'>Sending...</div>");
  
    $.ajax({
        url: "send-mail.php",
        method: "POST",
        data: $(this).serialize(),
        success: function(response) {
            $("#formStatus").html("<div class='alert alert-success'>" + response + "</div>");
            $("#contactForm")[0].reset();
        },
        error: function() {
            $("#formStatus").html("<div class='alert alert-danger'>Failed to send message. Try again.</div>");
        }
    });
});
</script>

And lastly Create a file named send-mail.php in the same directory as your HTML file with
PHP:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $to = "yourreceiver@example.com"; // where you want to receive the emails
    $name = strip_tags(trim($_POST["name"]));
    $email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);
    $subject = strip_tags(trim($_POST["subject"]));
    $message = strip_tags(trim($_POST["message"]));

    if (empty($name) || empty($email) || empty($subject) || empty($message)) {
        echo "Please fill out all fields.";
        exit;
    }

    // For better deliverability, use your domain email as the actual sender
    $from = "demo@gmail.com"; // your actual sender account
    $headers = "From: $name <$from>\r\n";
    $headers .= "Reply-To: $email\r\n";
    $headers .= "Content-Type: text/plain; charset=UTF-8\r\n";

    $body = "New message from your website contact form:\n\n";
    $body .= "Name: $name\n";
    $body .= "Email: $email\n";
    $body .= "Subject: $subject\n";
    $body .= "Message:\n$message\n";

    if (mail($to, "Contact Form: $subject", $body, $headers)) {
        echo "Message sent successfully!";
    } else {
        echo "Error sending message. Check your mail configuration.";
    }
} else {
    echo "Invalid request.";
}
?>

If you do these changes then your mail system should start working.
 
Back
Top Bottom