I have php that consists of an if statement followed by several elseif statements. For some reason i cannot get the if statement to ever return a true value and output the corresponding message. It has nothing to do with (I think) the $_POST method because all of the elseif statements work with their $_POST methods. I want the if statement to return a true value if nothing has been entered in the corresponding field.
if(!isset($_POST['phpro_username'],$_POST['phpro_password'],
$_POST['phpro_password1']))
{
$message = 'Please enter a valid username and password';
}
/*check to make sure the form is the one
* from the browser*/
elseif ($_POST['form_token'] != $_SESSION['form_token'])
{
$message = 'Invalid Form Submission';
}
elseif (strlen($_POST['phpro_username']) > 20 ||
strlen($_POST['phpro_username']) < 4 )
{
$message = 'Username Invalid';
}
There are a few other elseif statements after this, and if any of the elseif statements are not true then i get the correct message. Its just the first if statement that does not work. Here is my code for posting the variables (password/username)
<form id="signup_form" action="adduser_submit.php" method="post">
<fieldset>
<p class="loginfield" id="Username">
<label for="phpro_username">Create Username</label><br>
<input type="text" id="phpro_username" name="phpro_username" value="" maxlength="20" />
</p>
<p class="loginfield" id="Password">
<label for="phpro_password">Create Password</label><br>
<input type="text" id="phpro_password" name="phpro_password" value="" maxlength="20" />
</p>
<p class="loginfield" id="Re-enter Password">
<label for="phpro_password1">Re-enter Password</label><br>
<input type="text" id="phpro_password1" name="phpro_password1" value="" maxlength="20" />
</p>
<p>
<input type="hidden" name="form_token" value="<?php echo $form_token; ?>" />
<div id="submit_button" >
<input type="submit" value="→ Sign Up" />
</div>
</p>
</fieldset>
</form>
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire