Jump to content

Reaper0167

Members
  • Posts

    270
  • Joined

  • Last visited

    Never

Everything posted by Reaper0167

  1. I have been going at this for a week now and it is starting to drive me crazy. I have a form with a couple of fields, three to be exact with a submit button. if one of the fields is not filled in and left blank I would like to have an error message appear to the right of the text field. i don't like the pop up error messages in a separate window(looks unprofessional). are there any tutorials out there to help me out, or could someone throw me a bit of code to work with. thanks. sorry about all the posts about this.
  2. i know i keep posting new threads on this subject but i can't find a good tutorial on using javascript to dispaly a message next to a field if it is empty when the submit button is clicked. sorry guys/girls
  3. lets say you have 5 fields on a form. if a field is left empty and the user clicks the submit button, could some text appear to the right of the field letting the user know that it must be filled in. couldn't you hide the error text and when the submit button is clicked you could do something like if empty then show text if anyone has any input,, please share,, thanks
  4. thanks,,,, gotta love that google page,,,,lol,,,,lol
  5. acually, i'm not looking for a pop up window,,, just text that appears on the same page as my form.
  6. thanks dropfaith.... i have been looking everywhere for this.
  7. oh yeh,, here is my form <?php <form id="register" name="register" method="post" action="register.php"> <table width="100%" border="0" cellspacing="5" cellpadding="0"> <tr> <td width="30%"><div align="right"> <label for="label3">Username</label> </div></td> <td width="70%"><input name="username" type="text" id="label3" size="35" maxlength="20" /></td> </tr> <tr> <td><div align="right">Password</div></td> <td><input name="password" type="password" id="label4" size="35" maxlength="20" /></td> </tr> <tr> <td height="22"><div align="right"> <label for="label4"></label> Email</div></td> <td><input name="email" type="text" id="label5" size="35" maxlength="65" /></td> </tr> <tr> <td height="22"> </td> <td><label for="submit"></label> <input type="submit" name="submit" id="submit" value="Register" /></td> </tr> </table> </form> ?>
  8. i had a post a few days ago about a register script and we finally got that all figured out. but right now when the user doesn't fill in all three of the fields it directs them to another page with a message saying that the field was not filled in. and well, it just doesn't look professional. what i am hoping we can do is get the message to appear next to the field that was not filled in. i was told that this can not be done using PHP and javascript must be used. is that true? can anyone help me out here? thanks, Reaper. Oh yeh, here is what i got so far <?php //connection to your database include ("connection.php"); // define variables from register form $username = mysql_real_escape_string($_POST["username"]); $password = mysql_real_escape_string($_POST["password"]); $email = mysql_real_escape_string($_POST["email"]); $encrypted_password = md5($password); // display message if field is empty if (empty($username)) { echo "Please enter a username."; } elseif (empty($password)) { echo "Please enter a password."; } elseif (empty($email)) { echo "Please enter a valid email."; } else { // take user to a page after registration header("location:thanks.php"); } if (isset($_POST['submit'])) { // inserting data into your database $sql = "INSERT INTO $tbl_name(username, password, email)VALUES('$username','$encrypted_password','$email')"; $res = mysql_query($sql) or die(mysql_error()); // closes your connection mysql_close(); } ?>
  9. keeping my form the way it was,,, this worked thanks redarrow <?php // server and database variable information $host = "10.6.186.33"; $username = "mylahstone"; $password = "******"; $db_name = "mylahstone"; $tbl_name = "members"; // connects to server and database mysql_connect("$host", "$username", "$password") or die("Could not connect."); mysql_select_db("$db_name") or die("Could not find database"); // define variables from form $username = mysql_real_escape_string($_POST["username"]); $password = mysql_real_escape_string($_POST["password"]); $email = mysql_real_escape_string($_POST["email"]); $encrypted_password = md5($password); // display message if field is empty if (empty($username)) { echo "Please enter a username."; } elseif (empty($password)) { echo "Please enter a password."; } elseif (empty($email)) { echo "Please enter a valid email."; } else { // take user to a page after registration header("location:thanks.php"); } if (isset($_POST['submit'])) { // inserting data into your database $sql = "INSERT INTO $tbl_name(username, password, email)VALUES('$username','$encrypted_password','$email')"; $res = mysql_query($sql) or die(mysql_error()); // closes your connection mysql_close(); } ?>
  10. here is the form <?php <style type="text/css"> <!-- .style1 {font-size: 24px} .underline { border-bottom-width: thin; border-bottom-style: solid; border-bottom-color: #666666; } .style2 { color: #0000FF; font-weight: bold; font-style: italic; } .style3 {color: #FF0000} --> </style> <table width="100%" height="28" border="0" cellpadding="0" cellspacing="0" class="underline"> <tr> <td height="26" bgcolor="#CCCCCC"><div align="center"><strong><span class="style1">Justin's Simple Registration Script</span></strong></div></td> </tr> </table> <p align="center"> <label for="username"></label> </p> <form id="register" name="register" method="post" action="register.php"> <table width="100%" border="0" cellspacing="5" cellpadding="0"> <tr> <td width="45%"><div align="right"> <label for="label3">Username</label> </div></td> <td width="55%"><input name="username" type="text" id="label3" size="35" maxlength="20" /></td> </tr> <tr> <td><div align="right">Password</div></td> <td><input name="password" type="password" id="label4" size="35" maxlength="20" /></td> </tr> <tr> <td height="22"><div align="right"> <label for="label4"></label> Email</div></td> <td><input name="email" type="text" id="label5" size="35" maxlength="65" /></td> </tr> <tr> <td height="22"> </td> <td><label for="submit"></label> <input type="submit" name="submit" id="submit" value="Register" /></td> </tr> </table> </form> ?>
  11. this is driving me crazy. still, all three fields filled out, and its saying to enter a username <?php // server and database variable information $host = "--------"; $username = "--------"; $password = "---------"; $db_name = "-----------"; $tbl_name = "------------"; // connects to server and database mysql_connect("$host", "$username", "$password") or die("Could not connect."); mysql_select_db("$db_name") or die("Could not find database"); // define variables from form $username = $_POST["username"]; $password = $_POST["password"]; $email = $_POST["email"]; $encrypted_password = md5($password); // inserting data into your database $sql = "INSERT INTO $tbl_name(username, password, email)VALUES('$username','$encrypted_password','$email')"; // display message if field is empty if (empty($username)) { echo "Please enter a username."; } elseif (empty($password)) { echo "Please enter a password."; } elseif (empty($email)) { echo "Please enter a valid email."; } else { $result = mysql_query($sql); // take user back to a page header("location:register.php"); } // closes your connection mysql_close(); ?>
  12. still, nothing works. keeps saying to enter a username even when all fields are filled in. i haven't tried setting it up using an array yet. i will use that as my last resource. this way just seems a little more simple for being a beginner to PHP. <?php // server and database variable information $host = "-----------"; $username = "----------"; $password = "----------"; $db_name = "-----------"; $tbl_name = "------------"; // connects to server and database mysql_connect("$host", "$username", "$password") or die("Could not connect."); mysql_select_db("$db_name") or die("Could not find database"); // define variables from form $username = $_POST["username"]; $password = $_POST["password"]; $email = $_POST["email"]; $encrypted_password = md5($password); // inserting data into your database $sql = "INSERT INTO $tbl_name(username, password, email)VALUES('$username','$encrypted_password','$email')"; // display message if field is empty if ($username == '') { echo "Please enter a username."; } elseif ($password == '') { echo "Please enter a password."; } elseif ($email == '') { echo "Please enter a valid email."; } else { $result = mysql_query($sql); // take user back to a page header("location:register.php"); } // closes your connection mysql_close(); ?>
  13. i was trying to keep this as simple as possible, but I will take a look at doing it that way tomorrow, thanks for the tip. I just started with PHP so I have sticky notes all over the place until I get the hang of things. thanks again.
  14. think i just found the prob no, i didn't, sorry
  15. still having the same problem <?php // connects to server and database mysql_connect("$host", "$username", "$password") or die("Could not connect."); mysql_select_db("$db_name") or die("Could not find database"); // define variables from form $username = $_POST["username"]; $password = $_POST["password"]; $email = $_POST["email"]; $encrypted_password = md5($password); // inserting data into your database $sql = "INSERT INTO $tbl_name(username, password, email)VALUES('$username','$encrypted_password','$email')"; // display message if field is empty if ($username == '') { echo "Please enter a username."; } elseif ($password == '') { echo "Please enter a password."; } elseif ($email == '') { echo "Please enter a valid email."; } else { $result = mysql_query($sql); // take user back to a page header("location:register.php"); } // closes your connection mysql_close(); ?>
  16. still having a small problem. even with all three fields filled out i am still getting the message "Please enter a username" I'm stumped. oh yeh, how do you get the code to be color coded when you paste it in here for a post. // define variables from form $username = $_POST["username"]; $password = $_POST["password"]; $email = $_POST["email"]; $encrypted_password = md5($password); // inserting data into your database $sql = "INSERT INTO $tbl_name(username, password, email)VALUES('$username','$encrypted_password','$email')"; // display message if field is empty if (empty($username)) { echo "Please enter a username."; } elseif (empty($password)) { echo "Please enter a password."; } elseif (empty($email)) { echo "Please enter a valid email."; } else { $result = mysql_query($sql); // take user back to a page header("location:register.php"); } // closes your connection mysql_close(); ?>
  17. thanks for your time bud. if anyone else has any other suggestions, feel free. thanks again!
  18. i'm have three text fields for name, email and password. if one or more is not filled in, i'm looking to have an error message appear to the right of the text field. (ex: Name is required, or Email is required) and so on. What is the simplest way to do achieve this. I am new to PHP and I cannot find a simple solution anywhere. here is what i have so far for adding the completed fields to the database. my form name on my index page is named "register" <?php /* server and database information */ $host="--------"; $username="-----------"; $password="-----------"; $db_name="----------"; $tbl_name="members"; /* connects to server and database */ mysql_connect("$host","$username","$password")or die("Could not connect."); mysql_select_db("$db_name")or die("Could not find database"); /* define variables from form */ $username=$_POST["username"]; $password=md5($_POST["password"]); $email=$_POST["email"]; /* inserting data into your database */ $sql="INSERT INTO $tbl_name(username, password, email)VALUES('$username','$password','$email')"; $result=mysql_query($sql); /* success or error text display */ if($result){ echo "Thank you for registering."; } else { echo "ERROR"; } /* closing your connection */ mysql_close(); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.