Max Njoroge Max Njoroge - 6 months ago 27x
PHP Question

Contact form not sending form values

I am using an upgrade version of stepsForm.js from codrops. Anyway the contact form sends the email but none of the values from the input i.e

. The PHP...


$field_email = $_POST['email'];
$field_name = $_POST['name'];
$field_residence = $_POST['residence'];
$field_profession = $_POST['profession'];
$field_club = $_POST['fave_club'];
$field_message = $_POST['message'];

$mail_to = '';
$subject = 'Message from vidz.dundaah visitor '.$field_name;

$body_message = 'E-mail: '."\n".$field_email."\n\n";
$body_message .= 'Name: '."\n".$field_name."\n\n";
$body_message .= 'Residence: '."\n".$field_residence."\n\n";
$body_message .= 'Profession: '."\n".$field_profession."\n\n";
$body_message .= 'Fave_club: '."\n".$field_club."\n\n";
$body_message .= 'Message: '."\n".$field_message;

$headers = 'From: '.$field_name."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";

$mail_status = mail($mail_to, $subject, $body_message, $headers);

<script type="text/javascript">
window.location = '../contact.html';


The HTML form... and js file stepsForm.js and css file stepsForm.css

<section class="cool_form">
<form action="css/contactForm.php" id="theForm" class="simform" autocomplete="off">
<div class="simform-inner">
<ol class="questions">
<span><label for="q1">What's your email?</label></span>
<input id="q1" name="email" type="email" spellcheck="false" />
<span><label for="q2">What's your name?</label></span>
<input id="q2" name="name" type="text" spellcheck="false" />
<span><label for="q3">Where do you live?</label></span>
<input id="q3" name="residence" type="text" spellcheck="false" />
<span><label for="q4">What do you do?</label></span>
<input id="q4" name="profession" type="text" spellcheck="false" />
<span><label for="q5">Favourite club?</label></span>
<input id="q5" name="fave_club" type="text" spellcheck="false" />
<span><label for="q6">Tell us something...</label></span>
<input id="q6" name="message" type="text" spellcheck="false" />
<button class="submit" type="submit">Send answers</button>
<div class="controls">
<button class="previous"></button>
<button class="next"></button>
<div class="progress"></div>
<span class="number">
<span class="number-current"></span>
<span class="number-total"></span>
<span class="error-message"></span>
<span class="final-message"></span>

basically getting "Email: blank space", "Name: blank.." etc. thank you!


You need to add method="post" to your HTML <form> tag. Forms will default to $_GET unless you specify to use a different HTTP request method. If you look at your address bar after submitting your existing form, you'll probably see all the submitted parameters in the URL.

Here's how your <form> tag should look:

<form action="css/contactForm.php" id="theForm" class="simform" autocomplete="off" method="post">