problems with $_POST returning NULL values in php 4.4.2

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
okay. so all i am doing is changing a registration script that uses
$_GET to a script that uses $_POST, but the validation script now
returns NULL values for all posted vars.

What's the deal?

NOTE: when i use $_GET the script just works.

Thanks in advance for helping a noob.

script with the form:
 // Connect to a session
  session_start( );
<form method="POST" action="reg_validate.php">
<h2>User Profile</h2>

  // Show meaningful instructions for UPDATE or INSERT or errors
          if (session_is_registered("loginUsername"))
                  echo "<p><b>Please update your profile below as
                  echo "<p><b>Please fill in all details below to
          // Display error message to the user
<col span="1" align="right">

   <tr><td>User Name:</td>
   <td><? echo fieldError("userName", $errors); ?>
       <input type="text" name="userName"
      value="<? echo $formVars["userName"]; ?>"

    <tr><td>Real Name:</td>
   <td><? echo fieldError("realName", $errors); ?>
       <input type="text" name="realName"
      value="<? echo $formVars["realName"]; ?>"

   <td><select name="title">
       <option <?php if ($formVars["sex"]=="M")
                 echo "selected";?>>M
       <option <?php if ($formVars["sex"]=="F")
                 echo "selected";?>>F

   <td><? echo fieldError("city", $errors); ?>
       <input type="text" name="city"
      value="<? echo $formVars["city"]; ?>"

    <td><? echo fieldError("state", $errors); ?>
   <input type="text" name="state"
       value="<? echo $formVars["state"]; ?>"

    <td><? echo fieldError("zipcode", $errors); ?>
   <input type="text" name="zipcode"
       value="<? echo $formVars["zipcode"]; ?>"

   <td><? echo fieldError("country", $errors); ?>
   <input type="text" name="country"
       value="<? echo $formVars["country"]; ?>"

    <tr><td>Date of birth (dd/mm/yyyy): </td>
   <td><? echo fieldError("dob", $errors); ?>
       <input type="text" name="dob"
      value="<? echo $formVars["dob"]; ?>"

  // Only show the username/email and password
  // <input> widgets to new users
  if (!session_is_registered("loginUsername"))
?>    <tr><td>Email:</td>
   <td><? echo fieldError("email", $errors); ?>
       <input type="text" name="email"
      value="<? echo $formVars["email"]; ?>"

   <td><? echo fieldError("loginPassword", $errors); ?>
       <input type="password" name="loginPassword"
      value="<? echo $formVars["loginPassword"]; ?>"

    <tr><td><img src="/captcha.php"></td>
   <td><? echo fieldError("loginCaptcha", $errors); ?>
       Type in the text from the image to the left<br/>
       <input type="text" name="loginCaptcha"
      value="" size=8></td>

   <td><input type="submit" value="Submit"></td>
        //prevent session hijacks by clearing sessions once
informations is
        // Clear the formVars so a future <form> is blank

validation snippet:
(not including all the validation just the meat where the vars are
being grabbed)

  // Initialize a session

  // Register an error array - just in case!
  if (!session_is_registered("errors"))

  // Clear any errors that might have been
  // found previously
  $errors = array();
  $formVars = array();

  // Set up a $formVars array with the POST variables
  // and register with the session.
  if (!session_is_registered("formVars"))

  // TO DO remove $HTTP_GET_VARS and use all $_GET variables
  // TO DO use $_POST
  $formVars["userName"] = clean($_POST["userName"],50);
  $formVars["realName"] = clean($_POST["realName"], 50);
  $formVars["sex"] = clean($_POST["sex"], 50);
  $formVars["city"] = clean($_POST["city"], 50);
  $formVars["state"] = clean($_POST["state"], 50);
  $formVars["zipcode"] = clean($_POST["zipcode"], 50);
  $formVars["country"] = clean($_POST["country"], 50);
  $formVars["dob"] = clean($_POST["dob"], 50);
  $formVars["email"] = clean($_POST["email"], 50);
  $formVars["loginPassword"] = clean($_POST["loginPassword"], 50);
  $formVars["loginCaptcha"] = clean($_POST["loginCaptcha"], 50);


Re: problems with $_POST returning NULL values in php 4.4.2

figured out a workaround for $_POST

instead of calling $_POST while assigning to my session array
$form_vars like this:
$formVars["userName"] = clean($_POST["userName"],50);

i call $_POST to a normal var $userName like this:
$userName = $_POST["userName"];

then do
$formVars["userName"] = clean($userName,50);

however, this does not explain why
$formVars["userName"] = clean($_GET["userName"],50);

works when using get method while
$formVars["userName"] = clean($_POST["userName"],50);

doesn't when using post method.

so flummoxed,

Site Timeline