![]() |
|
#1
|
|||
|
|||
Form Validation IssueHello
Iam new to this forum and hope i can get this awnsered. I have a form that lets users submit data online. Now i check my sql database to see if they arent submitting a duplicate username. How can i get the error message to appear on the form? You have this done when you register for this forum. I need to connect to the database and if there is a error display it on the form??? Below is a simple form can i have an example with thsi form where an dhow would i add the php to A check the database field(userid) and B) Submit the form into the database. I think i have to use php echo self thanks pete Form: <meta http-equiv="Content-Language" content="en-us"> <form method="POST" action="--WEBBOT-SELF--"> <p>Name: <input type="text" name="T1" size="20"></p> <p>Username: <input type="text" name="T3" size="20"></p> <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p> </form> |
|||
|
#2
|
||||
|
||||
|
Quote:
One way is to redisplay your form passing it an error code. Then in the PHP if error code exists you add a line above the form itself indicating what's wrong. In essence: Code:
__________________
During the election they said Obama could only be elected when pigs fly. Well, we currently have an epidemic of Swine Flu. Coincidence? |
|
#3
|
|||
|
|||
almost theirOk so now i have the code you gave me but how do i tie it in with my mysql. below you will find the sql im checking for in my database
You guys gave me this example, how do i tie in mysql with you code. Im checking for a duplicate username, if duplicate want the message to show on the form. $errline = ""; if ($err == 1) { $errline = "Name Error"; } else if ($err == 2) { $errline = "Address Error"; } print $errline print "<FORM ..." heres my COde: $query1 = "SELECT * from test WHERE name = '$user'"; $result1 = mysql_query($query1) or exit(mysql_error()); if (mysql_num_rows($result1)) PS Great Forum |
|
#4
|
||||
|
||||
|
How do you know if there's an error? I assume you know how to test for this. So when you get one, set the error code, and reload the form with the error as part of the query string.
__________________
During the election they said Obama could only be elected when pigs fly. Well, we currently have an epidemic of Swine Flu. Coincidence? |
Recent GIDBlog
Programming ebook direct download available by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PHP form needs validation | jabesign | MySQL / PHP Forum | 16 | 05-Jan-2005 01:23 |
| Help! Some basal questions about MFC | xutingnjupt | MS Visual C++ / MFC Forum | 1 | 05-Dec-2004 04:38 |
| PHP/MySQL coding issue | cmarti | MySQL / PHP Forum | 3 | 26-Jul-2004 09:01 |
| help with form | orbitel | MySQL / PHP Forum | 11 | 21-Jan-2004 16:29 |
| Why doesnt my form work correctly? | rhino1616 | Web Design Forum | 2 | 06-Nov-2003 18:21 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The