Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

[noob] php help needed

Options
  • 16-06-2012 9:50am
    #1
    Registered Users Posts: 4,941 ✭✭✭


    Hi, I had a contact form created for a personal website with php so that it would email me the form data on submission and it was all working fine, but I have done something to it and now the inputted fields on the form are not picked up on submission. The form still emails me, but has no inputted data.

    My php code:

    <?php
    $to ='myemail@gmail.com';
    $subject = 'RSVP reply';

    //variables from form
    $First_Guest = $_POST;
    $Second_Guest = $_POST;
    $Wedding_attendance = $_POST;
    $Dietary = $_POST;
    $Dietary_Requirements = $_POST;
    $Saturday_night = $_POST;


    $message = <<<EMAIL
    /*text First guest comes through on email, but not the value for $First_Guest */
    First guest $First_Guest
    Second guest $Second_Guest
    Attendance $Wedding_attendance
    Dietary requirement $Dietary
    Other requirements $Dietary_Requirements
    Saturday attendance $Saturday_night

    EMAIL;

    $header = 'Wedding guest RSVP'; //This comes through ok

    mail($to, $subject, $message, $header);

    ?>The form I'm using:
    <form name="form1" method="post" action="?" >
    <table width="835" border="1" align="center" cellpadding="5" cellspacing="5">
    <tr>
    <td colspan="2" bgcolor="#FFFFF0"><strong>Please Give Your name(s) & Select One Option For Attending The Wedding.</strong></td>
    </tr>
    <tr>
    <td bgcolor="#FFFFF0">Name of Guest 1 </td>
    <td align="left" bgcolor="#FFFFF0"><label for="First_Guest"></label>
    <input name="First_Guest" type="text" id="First_Guest" size="50" maxlength="50"></td>
    </tr>
    <tr>
    <td bgcolor="#FFFFF0">Name of Guest 2 </td>
    <td align="left" bgcolor="#FFFFF0"><label for="Second_Guest"></label>
    <input name="Second_Guest" type="text" id="Second_Guest" size="50" maxlength="50"></td>
    </tr>

    <tr>
    <td width="400" bgcolor="#FFFFF0">Attending The Wedding</td>
    <td width="400" align="left" bgcolor="#FFFFF0"><p>
    <label id="Wedding_attendance">
    <input type="radio" name="Wedding_attendance" value="Both will be attending " id="Wedding_attendance">
    Both will be attending</label>
    <br>
    <label>
    <input type="radio" name="Wedding_attendance" value="One shall be attending" id="Wedding_attendance">
    One shall be attending</label>
    <br>
    <label>
    <input type="radio" name="Wedding_attendance" value="None can attend " id="Wedding_attendance">
    None can attend</label>
    <br>
    </p></td>
    </tr>

    <tr>
    <td colspan="2"> </td>
    </tr>
    <tr>
    <td colspan="2" bgcolor="#FFFFF0"><strong>Please Let Us Know Of Any Special Requirements You May Have.</strong></td>
    </tr>
    <tr>
    <td bgcolor="#FFFFF0">Dietary Requirements</td>
    <td align="left" bgcolor="#FFFFF0"><p>
    <label>
    <input type="checkbox" name="Dietary" value="Vegetarian Option" id="Dietary_0">
    Vegetarian Option</label>
    <br>
    <label>
    <input type="checkbox" name="Dietary" value="Coeliac Option" id="Dietary_1">
    Coeliac Option</label>
    <br>
    </p></td>
    </tr>
    <tr>
    <td bgcolor="#FFFFF0">Please Specify Any Other Requirements</td>
    <td align="left" bgcolor="#FFFFF0"><label for="Dietary_Requirements"></label>
    <textarea name="Dietary_Requirements" cols="50" id="Dietary_Requirements"></textarea></td>
    </tr>
    <tr>
    <td colspan="2"> </td>
    </tr>
    <tr>
    <td colspan="2" bgcolor="#FFFFF0"><strong>Please Select One Option For Attending On The Saturday Night</strong></td>
    </tr>
    <tr>
    <td bgcolor="#FFFFF0">Saturday Night Festivities</td>
    <td align="left" bgcolor="#FFFFF0"><p>
    <label>
    <input type="radio" name="Saturday_night" value="Both will attend" id="Saturdaynight_0">
    Both will attend</label>
    <br>
    <label>
    <input type="radio" name="Saturday_night" value="One will attend" id="Saturdaynight_1">
    One will attend</label>
    <br>
    <label>
    <input type="radio" name="Saturday_night" value="None can attend" id="Saturdaynight_2">
    None can attend</label>
    <br>
    </p></td>
    </tr>
    <tr>
    <td colspan="2"> </td>
    </tr>
    <tr>
    <td align="center" bgcolor="#FFFFF0"><label for="Submit_form"></label>
    <input name="Submit_form" type="submit" id="Submit_form" onClick="MM_goToURL('parent','thank_You.html');return document.MM_returnValue" value="Submit"></td>
    <td align="center" bgcolor="#FFFFF0"><label for="Reset"></label>
    <input type="reset" name="Reset" id="Reset" value="Reset"></td>
    </tr>
    <tr>I'd be really grateful for any help here as I really need to get this working in the next few days.


Comments

  • Registered Users Posts: 92 ✭✭Jennyrose


    I don't see where the form is closed "</form>" - some browsers will forgive this, others wont

    have you tried building the string in this manner?
    $message = "First guest".  $First_Guest."\n";  
    $message .= "Second guest".  $Second_Guest."\n";
    etc
    


  • Registered Users Posts: 7,838 ✭✭✭Nulty


    Try debugging the form.

    [PHP]$First_Guest = "Var1";
    ...

    $message = $First_Guest;[/PHP]

    I think it's something in the form. Maybe unescaped characters?


  • Registered Users Posts: 4,941 ✭✭✭paulbok


    Problem was with a variable. All sorted now.
    Thanks.


  • Registered Users Posts: 45 irishd


    paulbok wrote: »
    Problem was with a variable. All sorted now.
    Thanks.

    Glad you got it working, but please don't even think about putting this script onto a live server, it will turn your website into a spam relaying engine.

    You need to bone up on "writing secure php code" !


Advertisement