felverick Posted September 20, 2007 Share Posted September 20, 2007 im fairly new to PHP and im trying to pass post data to a function that cleans the input. in zend studio im getting an error saying "call to undefined index firstName" this is the line of code. the variable isn't named $firstName as the values are being passed from html to the script. $firstName= clean_input($_POST['firstName'], array("notags","strtolower")); Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 20, 2007 Share Posted September 20, 2007 It means there is no 'firstName' being posted. What is your form's HTML Quote Link to comment Share on other sites More sharing options...
felverick Posted September 20, 2007 Author Share Posted September 20, 2007 <html> <head> <title></title> <body> <form action="emailform.php" method="post"> <table style="width: 100%" cellspacing="1" cellpadding="1" border="0" summary="User Account Form"> <tr> <td>First Name</td> <td><input type=text name= "firstName" size="15"></td> </tr> <tr> <td>Last Name</td> <td><input type=text name= "lastName" size="15"></td> </td> <tr> <td>Staff Number</td> <td><input type=text name= "staffNum" size="12"></td> </tr> <tr> <td>Queen's NetID</td> <td><input type=text name= "netID" size="12"></td> </tr> <tr> <td>Email Address</td> <td><input type=text name= "email" size="25"></td> </tr> <tr> <td>Address</td> <td><input type=text name= "address" size="25"></td> </tr> <tr> <td>City</td> <td><input type=text name= "city" size="20"></td> </tr> <tr> <td>Province</td> <td><input type=text name= "province" size="20" value="Ontario"></td> </tr> <tr> <td>Country</td> <td><input type=text name= "country" size="20" value="Canada"></td> </tr> <tr> <td>Postal Code</td> <td><input type=text name= "postalCode" size="8"></td> </tr> <tr><td></td> <td><input type="submit" value="Submit"></td></tr> </table> </form> </body> </head> </html> Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 20, 2007 Share Posted September 20, 2007 What do you see if you do print_r($_POST) on the top of the php page? Also, you might need to use isset() since if they leave the field blank I think it will cause this error. so it would be if(isset($_POST['firstName'])){ //your cleaning code }else{ //it was left blank } Quote Link to comment Share on other sites More sharing options...
Wuhtzu Posted September 20, 2007 Share Posted September 20, 2007 Isn't it because you try to use $_POST['firstName'] before it's been posted? Quote Link to comment 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.