Click to See Complete Forum and Search --> : What method do you think would be best?


oo7ml
05-07-2007, 08:21 AM
Hi, when a user submits my "join" form, an file called upload.processor is called which deals with the image upload and submission of the forms data into the database. All of the forms validation is done in javascript which checks everything before the form calls the upload.processor, however once the upload.processor forms is run, the first thing it does is checks if the username that the person filled in is already taken. If it is already taken, the error is displayed on the page and it refreshes back to the join page... but obviosly all of the data that the user entered in is gone and they have to start all over again...

So my question is, how could i solve this problem, what methods do you think would be best...

Here is the code that i have that checks if the username is already taken

if (!get_magic_quotes_gpc()) {
$_POST['username'] = addslashes($_POST['username']);
}
$usercheck = $_POST['username'];
$check = mysql_query("SELECT username FROM accounts WHERE username = '$usercheck'")
or die(mysql_error());
$check2 = mysql_num_rows($check);

//if the name exists it gives an error
if ($check2 != 0) {
die('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'."\n".
'"http://www.w3.org/TR/html4/strict.dtd">'."\n\n".
'<html lang="en">'."\n".
' <head>'."\n".
' <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">'."\n\n".
' <meta http-equiv="refresh" content="5;URL=http://localhost/site/join.form.php">'."\n\n".
' <link rel="stylesheet" type="text/css" href="Stylesheet.css">'."\n\n".
' <link rel="shortcut icon" href="Images/favicon.ico" >'."\n\n".
' <title>Upload Error</title>'."\n\n".
and so on etc...

bokeh
05-07-2007, 09:38 AM
This is a double post. The question has already been answered in the original thread (see post #8).

Can anyone do this (sort this)..... i'm lost ! (http://www.webdeveloper.com/forum/showthread.php?p=702338#post702338)