Jump to content

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.

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.