username not inserting into mysql database and more

the username for some reason is not registering in the mysql database- all other fields are. The second thing is when there is one record in the database- no matter what username you type in it comes back with the username already in use error.

Thank you and here is the php as well as the html form. The file is called “quote.php”

[php]<?php include_once(“scripts/connect.php”);
$message = ‘’;
if(isset($_POST[‘username’])){

$username = $_POST['username'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$pass1 = $_POST['pass1'];
$pass2 = $_POST['pass2'];
$vname = $_POST['vname'];
$vzip = $_POST['vzip'];
$event = $_POST['event'];
$date = $_POST['date'];
$guests = $_POST['guests'];
$hours = $_POST['hours'];

//error handleing
if ((!$username)||(!$fname)||(!$lname)||(!$email)||(!$pass1)||(!$pass2)||(!$vname)||(!$vzip)||(!$event)||(!$date)||(!$guests)||(!$hours)){
	$message="Please complete all fields in the form below";
	}else{
		if($pass1 != $pass2){
			$message = "Your password fields do not match!";
		}else{
		  //securing the data
		  
		 $username = preg_replace("#[*0-9a-z]#i","",$username);
		 $pass1 = sha1($pass1);
		 
		 $email = mysql_real_escape_string($email);
		 
		 //check for duplicates
		 $user_query = mysql_query("SELECT username FROM clients WHERE username='$username' LIMIT 1") or die ("Could not check username");
		 $count_username = mysql_num_rows($user_query);
		 
		 $email_query = mysql_query("SELECT email FROM clients WHERE email='$email' LIMIT 1") or die ("Could not check email");
		 $count_email = mysql_num_rows($email_query);
		 
		 if($count_username > 0){
		 	$message = "Your Username is already in use.";
		 	}else if($count_email > 0){
		 	$message = "Your Email is already registered";
		 	}else{
		 	// insert clients
		 	$query = mysql_query("INSERT INTO clients (username, firstName, lastName, email, password, vName, vZip, event, date, guests, hours)VALUES('$username','$fname','$lname','$email','$pass1','$vname','$vzip','$event','$date','$guests','$hours')")  or die('Could not insert your information');
			$client_id = mysql_insert_id();
			mkdir('events/$client_id',0755);
			$message = "Your quote has now been submitted and your account is registered. You will be receiving an email soon with more information. You may also log in above. ";
			
			
		 
		 
		}
	}
}

}

?>[/php]


		<form action="quote.php" method="post">
        User Name:<center><input type="text" name="username" placeholder="Username" /><br /></center>
		First Name:<center><input type="text" name="fname" placeholder="First Name" /><br /></center>
		Last Name:<center><input type="text" name="lname" placeholder="Last Name" /><br /></center>
		Email Address:<center><input type="text" name="email" placeholder="Email Address" /><br /></center>
		Password:<center><input type="password" name="pass1" placeholder="Password" /><br /></center>
		Validate Password:<center><input type="password" name="pass2" placeholder="Validate Password" /><br /></center>
		Venue Name:<center><input type="text" name="vname" placeholder="Venue Name" /><br /></center>
		Venue Zip Code:<center><input type="text" name="vzip" placeholder="Venue Zip Code" /><br /></center>
		Event Type:
		<center><select name="event">
		<option value="wedding">Wedding</option>
		<option value="dance">Dance</option>
		<option value="conference">Conference</option>
		<option value="birthday">Birthday</option>
		<option value="party">Party</option>
		<option value="other">Other</option>
		</select><br /></center>
		Date:<center><input type="date" name="date" placeholder="date" /><br /></center>
		Approx Guests:<center><input type="text" name="guests" placeholder="Approx Guests" /><br /></center>
		Hours:<center><input type="text" name="hours" placeholder="Hours Needed" /><br /></center>
		<input type="submit" value="Submit" />
		</form>
				

I’m not sure what you intended to do here but you are actually replacing all alphanumeric characters with nothing…

Red :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service