0

I have a contact form created with html css and php that is not sending the email.

The Goal: Create a working contact form with HTML and PHP

The Issue: Email never arrived when submitted and I'm never taken to the final email_success.php page. It only takes me to the blank page called thankyou.php

My codes are based on my recent question on stackoverflow (See link) contact form which I solved once being uploaded to my web host server.

Heres a screenshot of the form itself: enter image description here

My codes are the following -->

contact.php :

<!DOCTYPE HTML>
<html lang="sv">
<head>
    <meta charset="UTF-8">
    <!-- Iphone delete blue link styling -->
    <meta name="format-detection" content="telephone=no">
    <link rel="shortcut icon" href="_images/favicon.png" type="image/png">
    <title>Contact</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="_css/main.css" rel="stylesheet" media="screen, projection">
</head>
<body>

<!-- Contact Form -->

<div id="form_Holder_Contact_dk">

    <div id="form_Box_Contact_dk">

        <form action="thankyou.php" method="post" name="contact_form">  

            <!-- L E F T  C O L U M N -->
            <div id="columnLeft_Contact_dk">

                <!-- Name field -->
                <input type="text" name="name" placeholder="NAME">

                <!-- E-mail field -->
                <input type="text" name="email" placeholder="E-MAIL">

                <!-- Subject field -->
                <input type="text" name="subject" placeholder="SUBJECT">

            </div>

            <!-- R I G H T  C O L U M N -->
            <div id="columnRight_Contact_dk">

                <!-- Message field -->
                <textarea name="message" placeholder="LEAVE A MESSAGE">  </textarea>

                <!-- Send button -->
                <input type="submit" value="SEND" name="submit" placeholder="SEND">

            </div>

        </form>

    </div>

</div>

</body>
</html>

thankyou.php :

<?
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];

$email_message = "
Name: ".$name."
Email: ".$email."
Subject: ".$subject."
Message ".$message."

";

mail("my@emailexample.com" , "New inquiry" , $email_message);
header("Location: email_success.php");

?>

email_success.php :

<!DOCTYPE HTML>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Email Sent</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

<h1>Email sent</h1>

</body>
</html>

Could the error be the submit button that is not connecting the inputs and textarea that are placed in two different columns? I did create a name for the form called contact_form which is not in use.

I would highly appreciate your help, thank you!

Community
  • 1
  • 1
user5434403
  • 157
  • 2
  • 11

0 Answers0