Hello DIC,
I've been searching for quite few hours so I guess I'm safe to post a thread on my favorite programming website,
I've been working on a user system, a lot of it is done through tutorials because I'm doing this small project for learning purposes.
My problem is that when I want to log in, and certain fields are empty, it kills the site and displays a message.
What I'd like to do is to place that message inbetween the login form and the login button.
This is my whole login.php file,
the comments are in Dutch, but I don't think it's necessary to translate them.
This page is displayed upon loading the directory:
![Posted Image]()
The whole page turns into this when not enough information has been filled in:
![Posted Image]()
I'd like to have the error message displayed where the red line is:
![Posted Image]()
Thank you,
Worldofwar.
I've been searching for quite few hours so I guess I'm safe to post a thread on my favorite programming website,
I've been working on a user system, a lot of it is done through tutorials because I'm doing this small project for learning purposes.
My problem is that when I want to log in, and certain fields are empty, it kills the site and displays a message.
What I'd like to do is to place that message inbetween the login form and the login button.
<?php mysql_connect("no", "info", "foryou") or die(mysql_error()); mysql_select_db("denied") or die(mysql_error()); if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else { header("Location: members.php"); } } } if (isset($_POST['submit'])) { if(!$_POST['username'] | !$_POST['pass']) { die('<center>You didn\'t fill in all required information</center>'); } $check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error()); $check2 = mysql_num_rows($check); //Bestaat naam? if ($check2 == 0) { die('<center>That user does not exist in our database. <a href=register.php>Click Here to Register</a></center>'); } while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); if ($_POST['pass'] != $info['password']) { die('<center>Incorrect password, please try again.</center>'); } else { // cookie als login juist is $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(ID_my_site, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour); //naar member area header("Location: members.php"); } } } else { // als ze niet ingelogd zijn ?> <div class="bootstrap"> <center> <link href="css/bootstrap.min.css" rel="stylesheet" media="screen"> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table border="0"> <tr><td colspan="4" align="center"><h1>Login</h1></td></tr> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="40"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="pass" maxlength="50"> </td></tr> <tr><td colspan="2" align="center"> <button type="submit" name="submit" class="btn btn-primary">Log in</button> </td></tr> </table> </form> </center> <script src="js/bootstrap.min.js"></script> <style type="text/css"> body { padding-top: 40px; padding-bottom: 40px; background-color: #f5f5f5; } </style> <?php } ?>
This is my whole login.php file,
the comments are in Dutch, but I don't think it's necessary to translate them.
This page is displayed upon loading the directory:

The whole page turns into this when not enough information has been filled in:

I'd like to have the error message displayed where the red line is:

Thank you,
Worldofwar.