RossNB Posted August 1, 2008 Share Posted August 1, 2008 Hi All, I have a PHP form that has suddenly started throwing up the subjected error. The error occurs on each of the form values. The form code is posted below, please can anyone help me !! Thankyou in advance for any help. Regards Ross <form action="contact-thanks.php" method="post" name="form1" class="aText" id="form1" onSubmit="MM_validateForm('Name','','R','Company','','R','Address','','R','City','','R','PostCode','','R','Country','','R','Telephone','','R','Email','','RisEmail','Subject','','R','Message','','R');return document.MM_returnValue"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="30" colspan="2" class="aText"><span class="zHeaderContact">Enquiries </span></td> </tr> <tr> <td width="160" class="aText">Name:</td> <td height="25" valign="top" class="aText"><input name="Name" type="text" id="Name2" value="<?php echo $_GET['Name'];?>"/></td> </tr> <tr> <td width="160" class="aText">Company:</td> <td height="25" valign="top" class="aText"><input name="Company" type="text" id="Company2" value="<?php echo $_GET['Company'];?>"/></td> </tr> <tr> <td width="160" class="aText">Address:</td> <td height="25" valign="top" class="aText"><input name="Address" type="text" id="Address2" value="<?php echo $_GET['Address'];?>"/></td> </tr> <tr> <td width="160" class="aText">City:</td> <td height="25" valign="top" class="aText"><input name="City" type="text" id="City2" value="<?php echo $_GET['City'];?>"/></td> </tr> <tr> <td width="160" class="aText">Postcode:</td> <td height="25" valign="top" class="aText"><input name="PostCode" type="text" id="PostCode2" value="<?php echo $_GET['PostCode'];?>"/></td> </tr> <tr> <td width="160" class="aText">Country:</td> <td height="25" valign="top" class="aText"><input name="Country" type="text" id="Country2" value="<?php echo $_GET['Country'];?>"/></td> </tr> <tr> <td width="160" class="aText">Telephone:</td> <td height="25" valign="top" class="aText"><input name="Telephone" type="text" id="Telephone2" value="<?php echo $_GET['Telephone'];?>"/></td> </tr> <tr> <td width="160" class="aText">Your e-mail:</td> <td height="25" valign="top" class="aText"><input name="Email" type="text" id="Email2" value="<?php echo $_GET['Email'];?>"/></td> </tr> <tr> <td width="160" class="aText">Subject:</td> <td height="25" valign="top" class="aText"><input name="Subject" type="text" id="Subject2" value="<?php echo $_GET['Subject'];?>"/> </td> </tr> <tr> <td width="160" height="30" valign="middle" class="aText">Message:</td> <td height="110" rowspan="2" valign="top"><textarea name="Message" cols="30" rows="4" class="aText" id="Message2"><?php echo $_GET['Message'];?></textarea></td> </tr> <tr> <td width="160" valign="top" class="aText"><div align="left"><br> <input name="Submit" type="submit" value="Send Message"/> <br> <br> <input name="Reset" type="reset" id="Reset2" onClick="GP_popupConfirmMsg('Are You Sure You Want To Reset This Form.');return document.MM_returnValue" value="Clear Form"> </div></td> </tr> </table> </form> Link to comment https://forums.phpfreaks.com/topic/117705-notice-undefined-index-message-in-contactphp-on-line-167/ Share on other sites More sharing options...
GingerRobot Posted August 1, 2008 Share Posted August 1, 2008 That would be because the first time the page loads, there is nothing in the $_GET array, so each index is undefined. You should check to see if the variable is set before echoing it. You ought to be using htmlentities() too, otherwise you'll have problems if people include quotes. Like this: value="<?php echo (isset($_GET['Name'])) ? htmlentities($_GET['Name']) : '';?>" Edit: note that htmlentities() will not be required for the message. This is because it is not contained within double quotes as the value attribute. Link to comment https://forums.phpfreaks.com/topic/117705-notice-undefined-index-message-in-contactphp-on-line-167/#findComment-605420 Share on other sites More sharing options...
RossNB Posted August 1, 2008 Author Share Posted August 1, 2008 Hi GingerRobot, Thankyou for all help Cheers Ross Link to comment https://forums.phpfreaks.com/topic/117705-notice-undefined-index-message-in-contactphp-on-line-167/#findComment-605432 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.