Jump to content

simple problem, need help


felverick

Recommended Posts

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"));

Link to comment
https://forums.phpfreaks.com/topic/70015-simple-problem-need-help/
Share on other sites

 

 

  <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>

   

 

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
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.