Skip navigation
Fellows12
Currently Being Moderated

php form not including a field in the email sent to me

Mar 19, 2013 4:50 AM

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>

 
Replies
  • Currently Being Moderated
    Mar 19, 2013 5:02 AM   in reply to Fellows12

    $_REQUEST has been depricated as of PHP 5.3 and removed from PHP 5.4

     

    You are better off using $_POST instead

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 19, 2013 5:52 AM   in reply to Fellows12

    Your code looks right, curiously. Try adding this at the very top of the page just to make sure we have both feet on the ground -

     

    <?php if(array_key_exists('submit',$_POST)) { echo "<pre>";exit(print_r($_POST)); } ?>

     

    Let's see what is printed to the page when you submit the form.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 19, 2013 6:04 AM   in reply to Fellows12

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 19, 2013 6:27 AM   in reply to Fellows12

    So - wait. This is not what should have happened. Show us the code on the page now, please. All of it.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 19, 2013 6:38 AM   in reply to Fellows12

    The below is not in your original php you showed us. (of course you may have only showed us part of the php). Are you sure you are linking the form to the correct php processing form?

    Thank you!

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points