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

   

 

Link to comment
Share on other sites

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
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.