April 7, 201313 yr Can anyone help <?php $fname = $_Post['fname']; $email = $_Post['email']; $telephone = $_Post['telephone']; $date = $_Post['date']; $collection = $_Post['collection']; $rcollect = $_Post['rcollect']; $seats = $_Post['seats']; $destination = $_Post['destination']; $interest = $_Post['interest']; $like = $_Post['like']; $time = $_Post['time']; $method = $_Post['method']; $tc = $_Post['tc']; $formcontent="From: $fname, \n Telephone: $telephone, \n Date: $date, \n Collection Point: $collection, \n Collection Time from destination: $rcollect, \n Number of Seats: $seats, \n Destination: $destination, \n Interested In: $interest, \n Would Like A: $like, \n Best Time To Call: $time, \n Pereferred Method: $method, \n T&C Accpetance: $tc"; $recipient = "david@davidcook.me"; $subject = "Contact Form from Website"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader)or die("Error!"); echo "Thank You someone will be in contact in 24 hours"; ?> this is the php. <form method="post" action="contact.php" name="" > <table> <tbody> <tr> <td> <span class="wtxt">Full Name: </span> </td> <td class="wtxt">Email: </td> </tr> <tr> <td> <input name="fname" type="text" class="textfield" id="fname" /> </td> <td> <input name="email" type="text" class="textfield" id="email"/> </td> </tr> <tr> <td class="wtxt">Telephone: </td> <td class="wtxt">Date: </td> </tr> <tr> <td> <input name="telephone" type="text" class="textfield" id="telephone" /> </td> <td> <input name="date" type="text" class="textfield" id="date" /> </td> </tr> <tr> <td class="wtxt">Collection Point & Time: </td> <td class="wtxt">Time to collect from destination: </td> </tr> <tr> <td> <input name="collection" type="text" class="textfield" id="collection" /> </td> <td> <input name="rcollect" type="text" class="textfield" id="rcollect" /> </td> </tr> <tr> <td class="wtxt">Number of Seats Required: </td> <td class="wtxt">Destination: </td> </tr> <tr> <td> <input name="seats" type="text" class="textfield" id="seats" /> </td> <td> <input name="destination" type="text" class="textfield" id="destination" /> </td> </tr> <tr> <td class="wtxt">I'm interested in: </td> <td class="wtxt">I would like: </td> </tr> <tr> <td> <select name="interest" id="interest" class="selectfield"> <option value="Select Reason" selected="selected">Select</option> <option value="School Hire">School Hire</option> <option value="Sports Hire">Sports Hire</option> <option value="Private Hire">Private Hire</option> </select> </td> <td> <select name"like" id="like" class="selectfield"> <option value="Select Time" selected="selected">Select</option> <option value="A Callback">Callback</option> <option value="A Free Survey">Quote</option> </select> </td> </tr> <tr> <td class="wtxt">Best Time to call: </td> <td class="wtxt">Preferred method: </td> </tr> <tr> <td> <select name="time" id="time" class="selected"> <option value="Select Time" selected="selected">Select Time</option> <option value="Anytime">Anytime</option> <option value="Day Time">Day Time</option> <option value="Evening">Evening</option> </select> </td> <td> <select name="method" id="method" class="selected"> <option value="Select Time" selected="selected">Select</option> <option value="Phone Call">Phone Call</option> <option value="Email">Email</option> </select> </td> </tr> <tr> <td class="wtxt">T&C Acceptance: <br/> <a href="tc.html" style="color:white">Terms & Conditions</a></td> </tr> <tr> <td> <input name="tc" type="radio" class="textfield" id="terms" /> </td> </tr> <tr> <td colspan="2"> <input name="Submit" type="submit" class="button" value="Submit"/> </td> </tr> </tbody> </table> </form> the forms sends, however all the fields are blank. anyone able ago help.
April 7, 201313 yr $_Post should be capitalised to $_POST Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive. http://php.net/manual/en/language.variables.basics.php
April 7, 201313 yr Not sure where to start commenting on - there are a number of errors in your script. To start with you need to be looking for the $_POST variable. Then you need to check if anything is actually entered in the form as at the moment the email will be sent even if no data is entered. There is also a missing equals sign on this line. <select name"like" id="like" class="selectfield"> Correct these errors, do some validation and then report back.
April 7, 201313 yr Author thanks Andy it works now. thanks How would I go about creating this Terms & Conditions: (client needs to type I accept) in the box. thanks Edited April 7, 201313 yr by David Cook
April 7, 201313 yr <input type="checkbox" name="terms" value="accept"> if (isset($_POST['terms']) && $_POST['terms'] == "accept"){ // Accepted terms } else { // Did not accept terms }
Create an account or sign in to comment