stublackett Posted September 1, 2008 Share Posted September 1, 2008 Help....... I've got a PHP Contact Form and the message that the end user receieves is full of Errors Its saying this : The following was sent on 01/09/08(Mon) @ 14:15 from IP ...BLANKED OUT... --------------------------------------------------------- Name : <br /> <b>Notice</b>: Undefined variable: name in <b>\\nas31ent\domains\s\sunningdale-hotel.com\user\htdocs\contact.php</b> on line <b>105</b><br /> E-mail : <br /> <b>Notice</b>: Undefined variable: e_mail in <b>\\nas31ent\domains\s\sunningdale-hotel.com\user\htdocs\contact.php</b> on line <b>106</b><br /> Telephone : <br /> <b>Notice</b>: Undefined variable: tel in <b>\\nas31ent\domains\s\sunningdale-hotel.com\user\htdocs\contact.php</b> on line <b>107</b><br /> The code for the form is : <?php ini_set("sendmail_from", "enquiries@sunningdale-hotel.com"); $post_message = "0"; if ($_SERVER['REQUEST_METHOD'] == "POST") { $post_message = "1"; $name = $_POST['name']; $e_mail = $_POST['e_mail']; $tel = $_POST['tel']; $enquiry = $_POST['enquiry']; // $host_email = "user@user.com"; // Hidden for posting purposes $host_email = "user@user.com"; //Again hidden for posting purposes $email = "user@user.com"; // Same as above $subject = "The Sunningdale-hotel.com Enquiry"; $TimeOfMessage = date('d')."/".date('m')."/".date('y')."(".date('D').") @ ".date('H:i'); $ip = $_SERVER["REMOTE_ADDR"]; $message = "The following was sent on " .$TimeOfMessage." from IP " .$ip. "\n"; $message .= "---------------------------------------------------------\n"; $message .= "Name : " .$name. "\n"; $message .= "E-mail : " .$e_mail. "\n"; $message .= "Telephone : " .$tel. "\n"; $message .= "Enquiry : " .$enquiry. "\n"; mail($host_email, $subject, $message, "From: $name <$e_mail>"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/122225-solved-contact-form-producing-errors/ Share on other sites More sharing options...
DeanWhitehouse Posted September 1, 2008 Share Posted September 1, 2008 Try reading the error Notice: Undefined variable: tel in \\nas31ent\domains\s\sunningdale-hotel.com\user\htdocs\contact.php on line 107 What does it mean?? The var is undefined, it doesnt exist. Show the code for the form. Quote Link to comment https://forums.phpfreaks.com/topic/122225-solved-contact-form-producing-errors/#findComment-631062 Share on other sites More sharing options...
stublackett Posted September 1, 2008 Author Share Posted September 1, 2008 My suspicions are with the form itself, Yeah The variables are being set by the $_POST so the error should not be occuring, Like you say there is something in the form, If you can see what it is, Much appreciated <form name="signup" action="contact.php" method="POST"> <table align="center"> <tr> <td colspan="2" style="height: 5px"></td> </tr> <tr> <td class="labelcell">Name:</td> <td class="fieldcell"><input name="name" id="name" type="text" tabindex="1" /></td> </tr> <tr> <td class="labelcell">E-mail:</td> <td class="fieldcell"><input name="e_mail" id="e_mail" type="text" tabindex="2" /></td> </tr> <tr> <td class="labelcell">Telephone:</td> <td class="fieldcell"><input name="tel" id="tel" type="text" tabindex="3" /></td> </tr> <tr> <td class="labelcell" valign="top">Enquiry:</td> <td align="center"> <textarea name="enquiry" id="enquiry" tabindex="4"></textarea> <input name="name" type="hidden" value="<?php echo $name; ?>" /> <input name="e_mail" type="hidden" value="<?php echo $e_mail; ?>" /> <input name="tel" type="hidden" value="<?php echo $tel ; ?>" /> <br /> <br /> <input name="Submit" type="submit" value="Submit" class="buttons" tabindex="5"/> <input name="Reset" type="reset" value="Reset" class="buttons" tabindex="6" /> </td> </tr> <tr> <td class="labelcell2" colspan="2"><input name="Offers" type="checkbox" id="Offers" value="Sign Up" checked="checked" /> I would like to recieve email updates on special offers</td> </tr> <tr> </tr> </table> </form> Quote Link to comment https://forums.phpfreaks.com/topic/122225-solved-contact-form-producing-errors/#findComment-631065 Share on other sites More sharing options...
DeanWhitehouse Posted September 1, 2008 Share Posted September 1, 2008 <?php echo $name; ?> <?php echo $e_mail; ?> <?php echo $tel ; ?> These are not defined Without really looking just do <?php echo isset($name); ?> <?php echo isset($e_mail); ?> <?php echo isset($tel); ?> Quote Link to comment https://forums.phpfreaks.com/topic/122225-solved-contact-form-producing-errors/#findComment-631071 Share on other sites More sharing options...
stublackett Posted September 1, 2008 Author Share Posted September 1, 2008 Those issets' have come through as 1 1 1 Does the form really need those HIDDEN fields? Quote Link to comment https://forums.phpfreaks.com/topic/122225-solved-contact-form-producing-errors/#findComment-631073 Share on other sites More sharing options...
PFMaBiSmAd Posted September 1, 2008 Share Posted September 1, 2008 You have three hidden form fields with the same name as the normal form fields. The last field present with any name is the value that is sent. Why do you have those hidden fields in the form? Quote Link to comment https://forums.phpfreaks.com/topic/122225-solved-contact-form-producing-errors/#findComment-631075 Share on other sites More sharing options...
DeanWhitehouse Posted September 1, 2008 Share Posted September 1, 2008 oops, needed a bit more but no there not neaded , try this <td class="labelcell">Name:</td> <td class="fieldcell"><input name="name" id="name" type="text" tabindex="1" value="<?php if(isset($_POST['name'])){echo $_POST['name'];}" /></td> </tr> <tr> <td class="labelcell">E-mail:</td> <td class="fieldcell"><input name="e_mail" id="e_mail" type="text" tabindex="2" value="<?php if(isset($_POST['e_mail'])){echo $_POST['e_mail'];}" /></td> </tr> <tr> <td class="labelcell">Telephone:</td> <td class="fieldcell"><input name="tel" id="tel" type="text" tabindex="3" value="<?php if(isset($_POST['tel'])){echo $_POST['tel'];}" /></td> Quote Link to comment https://forums.phpfreaks.com/topic/122225-solved-contact-form-producing-errors/#findComment-631079 Share on other sites More sharing options...
stublackett Posted September 1, 2008 Author Share Posted September 1, 2008 Thanks for your help guys Solved Those HIDDEN fields, Just did not need to be there.... Thanks a lot though !! Quote Link to comment https://forums.phpfreaks.com/topic/122225-solved-contact-form-producing-errors/#findComment-631081 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.