seany02 Posted April 25, 2009 Share Posted April 25, 2009 I need to get this form to output something on the screen to let the user know the forms been successful. The sql and form work fine but once the submit button nothing is displayed onscreen indicating this. help please! <?php include("conf.inc.php"); // Includes the db and form info. if (!isset($_POST['submit'])) { // If the form has not been submitted. echo "<form action=\"register.php\" method=\"POST\">"; echo "<table>"; echo "<tr>"; echo "<td colspan=\"2\">Register:</td>"; echo "</tr>"; echo "<tr>"; echo "<td width=\"50%\">Username:</td><td width=\"50%\"><input name=\"username\" size=\"18\" type=\"text\" />"; echo "</tr>"; echo "<tr>"; echo "<td width=\"50%\">Password:</td><td width=\"50%\"><input name=\"password\" size=\"18\" type=\"text\" />"; echo "</tr>"; echo "<tr>"; echo "<td width=\"50%\">Email:</td><td width=\"50%\"><input name=\"email\" size=\"18\" type=\"text\" />"; echo "</tr>"; echo "<tr>"; echo "<td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"submit\"</td>"; echo "</tr>"; echo "</table>"; echo "</form>"; } else { // The form has been submitted. $username = form($_POST['username']); $password = md5($_POST['password']); // Encrypts the password. $email = form($_POST['email']); if (($username == "") || ($password == "") || ($email == "")) { // Checks for blanks. exit("There was a field missing, please correct the form."); } $q = mysql_query("SELECT * FROM `users` WHERE username = '$username' OR email = '$email'") or die (mysql_error()); // mySQL Query $r = mysql_num_rows($q); // Checks to see if anything is in the db. if ($r > 0) { // If there are users with the same username/email. exit("That username/email is already registered!"); } else { mysql_query("INSERT INTO `users` (username,password,email) VALUES ('$username','$password','$email')") or die (mysql_error()); // Inserts the user. } } mysql_close($db_connect); // Closes the connection. ?> Quote Link to comment https://forums.phpfreaks.com/topic/155627-help/ Share on other sites More sharing options...
Daniel0 Posted April 25, 2009 Share Posted April 25, 2009 Just echo something below the last call to mysql_query(). Quote Link to comment https://forums.phpfreaks.com/topic/155627-help/#findComment-819110 Share on other sites More sharing options...
seany02 Posted April 25, 2009 Author Share Posted April 25, 2009 how please? im such a novice its not funny. Quote Link to comment https://forums.phpfreaks.com/topic/155627-help/#findComment-819112 Share on other sites More sharing options...
Daniel0 Posted April 25, 2009 Share Posted April 25, 2009 Below this line: mysql_query("INSERT INTO `users` (username,password,email) VALUES ('$username','$password','$email')") or die (mysql_error()); // Inserts the user. Just echo something like this: echo 'Daniel is cool'; I don't know how else to explain it... Quote Link to comment https://forums.phpfreaks.com/topic/155627-help/#findComment-819113 Share on other sites More sharing options...
seany02 Posted April 25, 2009 Author Share Posted April 25, 2009 cheers much appreciated... like i said complete novice. Quote Link to comment https://forums.phpfreaks.com/topic/155627-help/#findComment-819115 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.