Rozmyślam właśnie jak przenieść frazy z dołu skryptu (te else z errorami) nad form z rejestracją (kod HTML na górze). Pierwsze co mi przyszło do głowy to przypisanie erroru do zmiennej i jego wyświetlenie, ale szybko zrozumiałem, że tak łatwo się tego nie da zrobić (chyba..).
Szukam po prostu pomysłu/podpowiedzi jak można taki problem rozwiązać.
<?php include("header.php"); ?> <html> <head> <title>Register</title> </head> <body> <h1>Register</h1> <?php ?> <p> <form action='register.php' method='POST'> <table> <tr> <td> Your full name: </td> <td> <input type="text" name="fullname" /> </td> </tr> <tr> <td> Choose a username: </td> <td> <input type="text" name="username" /> </td> </tr> <tr> <td> Choose a password: </td> <td> <input type="password" name="password" /> </td> </tr> <tr> <td> Repeat your password: </td> <td> <input type="password" name="repeatpassword" /> </td> </tr> <tr> <td> <input type="submit" name="submit" value="Register" /> </td> </tr> </table> </form> </body> </html> <?php // Get data from the form. $submit = $_POST['submit']; // Check if form is submitted. if ($submit) { // Connect to database server and select database. // Check if all data is present.. if ($username && $fullname && $password && $repeatpassword) { // Check if username already exists. if ($count == 0) { // Check if passwords match. if ($password == $repeatpassword) { // Check the length of username and full name. // Check the length of password. // If everything do this... // Encrypt passwords. // Insert user into database and show success message. $queryreg = mysql_query("INSERT INTO users VALUES ('','$fullname','$username','$password','$date')"); die("You have been <b>registered</b>. Click <a href='index.php'>here</a> to return to login page."); } }else { echo "You are already registered and logged in. Click <a href='members.php'>here</a> to enter the members area.<br />"; } footer(); ?>