hem853 Posted July 29, 2009 Share Posted July 29, 2009 Hi I'm new to phph so forgive me if this is a really dumb question! I am using PHP 5.1.6 I have a login form with the following code <?PHP # First we check to see if the user submitted the login form IF (ISSET($_GET['loginsubmit'])) { Echo ("Variables before: ".$_GET['suser']." ".$_GET['passwd']); # added for testing variables are set correctly # Now we check the user actually entered details in the form before they submitted it IF (($_GET['suser']=" ") || ($_GET['passwd']=" ")) { # If the user did not enter any details we print a message and exit. Echo ("<br>Variables after: ".$_GET['suser']." ".$_GET['passwd']); # added for testing variables are set correctly Echo ("<p>Sorry you did not enter a valid username and/or password"); Echo ("<p>Please <a href='quick_log_in.php' target='_self'>Try Again</a>."); exit; } ELSE { # dbstuff goes here. exit; } } ELSE # If the user did not submit the login form we show the form here. {?> <p align="center">Quick Log In</p><form method="GET" action="" name="user_sign_in"> Username<br> <input type="text" name="suser" size="12"><br> Password<br> <input type="password" name="passwd" size="12"> <br> <input type="submit" value="Log_In" name="loginsubmit"> </form> <?php } ?> You can see in this code I have added two Echo statements to show two variables before and after the second IF statement. Those two echo statements give different values for the first variable. What is happening is somewhere between the first and fifth line of this section of the code Echo ("Variables before: ".$_GET['suser']." ".$_GET['passwd']); # added for testing variables are set correctly # Now we check the user actually entered details in the form before they submitted it IF (($_GET['suser']=" ") || ($_GET['passwd']=" ")) { # If the user did not enter any details we print a message and exit. Echo ("<br>Variables after: ".$_GET['suser']." ".$_GET['passwd']); # added for testing variables are set correctly the value stored in the variable $_GET['suser'] is being changed to a null value or deleted. Anyone got any ideas why? I have set display_errors = On in php.ini in the hope this would show something up but it does not give any error message. Any help would be very much appreciated. Regards John Link to comment https://forums.phpfreaks.com/topic/168019-variable-value-disappears-o/ Share on other sites More sharing options...
arkansasonline Posted July 29, 2009 Share Posted July 29, 2009 IF (($_GET['suser']=" ") || ($_GET['passwd']=" ")) { is setting the values to " " use == IF (($_GET['suser']==" ") || ($_GET['passwd']==" ")) { Link to comment https://forums.phpfreaks.com/topic/168019-variable-value-disappears-o/#findComment-886181 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.