supergrame Posted March 16, 2009 Share Posted March 16, 2009 this is my problem $var = "hi"; i only call this value if password and username fields are empty my questions is can you stop the error or else set it to a value that wont show up untill the feilds are empty or am i trying to get this working in the wrong way. ill post the page just in case i don't make scene witch happens allot <?php if($_POST) { require_once("constants.php"); // Asighning the posted form data to variables for later use! $username = $_POST['username']; $password = $_POST['password']; // Check if the username and password fields were not empty! if(strlen($username) == 0 || strlen($password) == 0){ $var = "Please fill in all the required feilds"; } else { // To protect MySQL injection (more detail about MySQL injection) $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql="SELECT * FROM users WHERE username='$username' and password='$password'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $username and $password, table row must be 1 row if($count==1){ // Register $username, $password and redirect to file! session_register("username"); session_register("password"); header('Location: ../members/members.php'); } else { header('Location: ../index.php'); } } } ?> <html> <head> </head> <body> <div id="login"> <?php echo $var; ?> <form method="post" action=""> <table> <tr> <td colspan="2" align="center">Login or Register!</td> </tr> <tr> <td><label for="username">Username:</label></td> <td><input type="text" name="username"/></td> </tr> <tr> <td><label for="password">Password:</label></td> <td><input type="password" name="password"/></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" id="submit" value="Login" name="submit" /></td> </tr> </table> </form> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/149713-solved-var-unassighn-error-need-to-stop-the-error-or-go-about-this-difrently/ Share on other sites More sharing options...
rhodesa Posted March 16, 2009 Share Posted March 16, 2009 <?php if(isset($var)) echo $var; ?> Link to comment https://forums.phpfreaks.com/topic/149713-solved-var-unassighn-error-need-to-stop-the-error-or-go-about-this-difrently/#findComment-786145 Share on other sites More sharing options...
supergrame Posted March 16, 2009 Author Share Posted March 16, 2009 thank you that was a stupid question lol. i did no how to do that it just sliped my mind sorry for wasting time! thanks again Link to comment https://forums.phpfreaks.com/topic/149713-solved-var-unassighn-error-need-to-stop-the-error-or-go-about-this-difrently/#findComment-786181 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.