Jump to content

self processing form page is not working HELP!!


sardonicgem

Recommended Posts

Hey folks,

 

Before I start implementing a real log-in page, I'm trying to get my self processing form to check for empty fields. Instead, the empty form keeps getting returned whether the fields were filled or not.  I changed the form to use GET so I can see all the parameters for the time being.  Upon submission, I can see the paramters being carried through, but it's like the logic checks are being ignored and the form re-renders.  So according to this code, if the form is missing information, an error should be thrown, otherwise echo success.  Why isn't it working???

 

<?php

$in_name = $_GET["name"];

$in_pass = $_GET["pass"];

 

 

if (isset($_GET["submit"]))

{

  if ((!isset($in_name))||(!isset($in_pass)))

  {

      ?>

      <p><font color="red><b>"Oops ...you did not fill out all your user credentials</b></font></p>

      <?php

  }

  else

      echo "success";

}

else

{ // if page is not submitted to itself echo the form

?>

 

<form action="<?php echo $PHP_SELF;?>" method="GET" id="identity">

<p>Please Login</p>

<p> <label for="userName">Username: <input type="text" size="20" maxlength="20" id="userName" name="name"/></label></p>

<p> <label for="password">Password: <input type="text" size="10" maxlength="10" id="password" name="pass"/></label></p>

<p>New User? Click <a href="new.php">Here</a></p>

<p><center><input type="submit" value="submit"></center></p>

</form>

 

<?php

}

 

When you post (or get) something, a value is sent. It may be a value of nothing, but it's not a value of NULL (I have to admit, I'm not 100% sure what exactly IS passed though). You are setting the values of $in_name and $in_pass with the values that were passed. As such, the two variables were set.

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.