rofl90 Posted February 10, 2008 Share Posted February 10, 2008 I have here two files, a form, and a validate file as follows: * I can't see any problems, and I do define the variables here are the errors: Notice: Undefined index: Name in e:\domains\p\prowebdesigns.co.uk\user\htdocs\send.lib.php on line 5 Notice: Undefined index: Tel in e:\domains\p\prowebdesigns.co.uk\user\htdocs\send.lib.php on line 6 Notice: Undefined index: Email in e:\domains\p\prowebdesigns.co.uk\user\htdocs\send.lib.php on line 7 Notice: Undefined index: Website in e:\domains\p\prowebdesigns.co.uk\user\htdocs\send.lib.php on line 8 <?php $EmailFrom = "contacter@contacter.com"; $EmailTo = "email@myexample.com"; $Subject = "Contact form"; $Name = Trim(stripslashes($_POST['Name'])); $Tel = Trim(stripslashes($_POST['Tel'])); $Email = Trim(stripslashes($_POST['Email'])); $Website = Trim(stripslashes($_POST['Website'])); $Message = Trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=main.php\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Tel: "; $Body .= $Tel; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Website: "; $Body .= $Website; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=main.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=main.php\">"; } ?> and <html> <head> <link href="css/content_css.css" rel="stylesheet" type="text/css"> </head> <body class="mid-mid"> <div align="left"> <form name="frmFormMail" action="send.lib.php" method="post"> <table cellspacing='16' cellpadding='0' border='0' > <tr> <td width="334" align='right' valign='top' class="mid-mid">Name </td> <td width='18' aligh='right' valign='top'> <span class="mid-mid"><font size='2' color='#ff0000'>*</font> </span></td> <td colspan="2" class="mid-mid"> <input type="text" name="Name2"> </td> </tr> <tr> <td class="mid-mid" valign='top' align='right'>Phone </td><td width='18' aligh='right' valign='top'> </td> <td colspan="2" class="mid-mid"> <input type="text" name="Tel2"> </td> </tr> <tr> <td class="mid-mid" valign='top' align='right'>Email </td><td width='18' aligh='right' valign='top'> <span class="mid-mid"><font size='2' color='#ff0000'>*</font> </span></td> <td colspan="2" class="mid-mid"> <input type="text" name="Email2"> </td> </tr> <tr> <td class="mid-mid" valign='top' width="50" align='right'>Website </td> <td width='18' aligh='right' valign='top'></td> <td colspan="2" class="mid-mid"> <input type="text" name="Website2"> </td> </tr> <tr> <td class="mid-mid" valign='top' align='right'>Type </td><td width='18' aligh='right' valign='top'></td> <td width="342" class="mid-mid">Billing: <br /> Inquir: <br /> Sales <br /> Presales <br /> Quote <br /> Technical </td> <td width="342" class="mid-mid"> <input type="checkbox" name="Billing" value="Yes"> <br /> <input type="checkbox" name="Inquiry" value="Yes"> <br /> <input type="checkbox" name="Sales" value="Yes"> <br /> <input type="checkbox" name="Presales" value="Yes"> <br /> <input type="checkbox" name="Quote" value="Yes"> <br /> <input type="checkbox" name="Technical" value="Yes"> </td> </tr> <tr> <td class="mid-mid" valign='top' align='right'>Message </td><td width='18' aligh='right' valign='top'> <span class="mid-mid"><font size='2' color='#ff0000'>*</font> </span></td> <td colspan="2" class="form_text"><span class="mid-mid"> <textarea name="Message"></textarea> </span></td> </tr> <tr><td colspan=4 align='center' class="mid-mid"> <input name="Submit" type='submit' value='Submit'> <input name="Reset" type='reset' value='Cancel'> </td></tr> </table> </form> </span> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/90314-an-undefined-index-ooer/ Share on other sites More sharing options...
cooldude832 Posted February 10, 2008 Share Posted February 10, 2008 do print_r($_POST); however undefined indecies are one of the few errors you can ignore. Quote Link to comment https://forums.phpfreaks.com/topic/90314-an-undefined-index-ooer/#findComment-463093 Share on other sites More sharing options...
rofl90 Posted February 10, 2008 Author Share Posted February 10, 2008 Where do you think that should go, I never ignore any errors, as it nearly always does something to the script, never in my favor. Quote Link to comment https://forums.phpfreaks.com/topic/90314-an-undefined-index-ooer/#findComment-463096 Share on other sites More sharing options...
sasa Posted February 10, 2008 Share Posted February 10, 2008 try $Name = Trim(stripslashes($_POST['Name2'])); $Tel = Trim(stripslashes($_POST['Tel2'])); $Email = Trim(stripslashes($_POST['Email2'])); $Website = Trim(stripslashes($_POST['Website2'])); $Message = Trim(stripslashes($_POST['Message'])); Quote Link to comment https://forums.phpfreaks.com/topic/90314-an-undefined-index-ooer/#findComment-463097 Share on other sites More sharing options...
rcorlew Posted February 10, 2008 Share Posted February 10, 2008 You can only use lowercase names when calling a function for example: trim(stripslashes($_POST["var"])); not Trim(stripslashes($_POST["var"])); It should be in the php manual. Quote Link to comment https://forums.phpfreaks.com/topic/90314-an-undefined-index-ooer/#findComment-463107 Share on other sites More sharing options...
wildteen88 Posted February 10, 2008 Share Posted February 10, 2008 You can only use lowercase names when calling a function for example Functions are case-insensitive. Ony variables are case-sensitive @rofl90 Notices are not errors. I'd recommend you to change your code to: <?php if(isset($_POST['Submit'])) { $EmailFrom = "contacter@contacter.com"; $EmailTo = "email@myexample.com"; $Subject = "Contact form"; $Name = Trim(stripslashes($_POST['Name2'])); $Tel = Trim(stripslashes($_POST['Tel2'])); $Email = Trim(stripslashes($_POST['Email2'])); $Website = Trim(stripslashes($_POST['Website2'])); $Message = Trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=main.php\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Tel: "; $Body .= $Tel; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Website: "; $Body .= $Website; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=main.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=main.php\">"; } } ?> Your input fields where named as Name2, Tel2, Email2, Website2 etc rather than Name, Tel, Email, Website Quote Link to comment https://forums.phpfreaks.com/topic/90314-an-undefined-index-ooer/#findComment-463310 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.