I have tried to add a phone field to an existing form on my site, I just duplicated the existing email field and changed to say phone instead. The form works fine except that the email that comes through to me has all entered data from the form except for the phone field. Help would be great as I am a bit of a newbie.
Here is the mail.php:
<?php
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'] ;
$comments = $_REQUEST['comments'] ;
$message =
"
Name: $name\n
Email: $email\n
Phone: $phone\n
Comments: $comments
";
mail( "removedforprivacy", "Email from my website, sent by $name",
$message, "From: $email" );
?>
Here is the form HTML:
<form method="post">
<fieldset>
<ol>
<li>
<label for="name" id="name_label">Name</label>
<input id="name" type="" value="Your Name" name="name" class="text-input" />
<label class="error" for="name" id="name_error">This field is required.</label>
</li>
<li>
<label for="email" id="email_label">Email</label>
<input id="email" type="" value="Your Email" name="email" class="text-input" />
<label class="error" for="email" id="email_error">This field is required.</label>
</li>
<li>
<label for="phone" id="phone_label">Phone</label>
<input id="phone" type="" value="Your Phone" name="phone" class="text-input" />
<label class="error" for="name" id="phone_error">This field is required.</label>
</li>
<li>
<label for="comments" id="comments_label">Boston Brewery Booking Requested Date</label>
<textarea id="comments" type="" name="comments" class="text-input">Required Date</textarea>
<label class="error" for="comments" id="comments_error">This field is required.</label>
</li>
<li>
<button type="submit" name="submit" class="send" id="submit_btn" value="Send">Submit</button>
</li>
</ol>
</fieldset>
</form>
Your form and php works ok for me. I can't see a reason for it not to get the phone details.
What happens if you move the phone variable to the top of the stack (not that it should make any difference)
$phone = $_REQUEST['phone'] ;
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
Phone: $phone\n
Name: $name\n
Email: $email\n
Your enquiry has been submitted. We will be in touch with you soon.
There is no immediate reason for the phone details not being gathered on the evidence that you have shown us so far.
North America
Europe, Middle East and Africa
Asia Pacific