Well this is my register form, it all worked fine before but for some reason it isn't inserting anything into the table, all of my other scripts that insert items into a table.

A quick reply would be nice :) thank you.

Here is the Register Script:

<?php $title = "BlabSpot - Register"?>
<?php require("styles/top.php") ?>
<div id='full'>
<?php



if ($_POST['submitbtn']){
	$firstname = $_POST['firstname'];
			$lastname = $_POST['lastname'];
			$username = $_POST['username'];
			$email = $_POST['email'];
			$password = $_POST['password'];
			$repassword = $_POST['repassword'];
			$website = $_POST['website'];
			$youtube = $_POST['youtube'];
			$bio = $_POST['bio'];

	$name = $_FILES['avatar']['name'];
	$type = $_FILES['avatar']['type'];
	$size = $_FILES['avatar']['size'];
	$tmpname = $_FILES['avatar']['tmp_name'];
	$ext = substr($name, strrpos($name, '.'));


	if($firstname && $lastname && $username && $email && $password & $repassword){
		if($password == $repassword){
				if(strstr($email, "@") && strstr($email, ".") && (strlen($email) >= 6)){
					
				require("scripts/connect.php");
				$query = mysql_query("SELECT * FROM users WHERE username='$username'");
				$numrows = mysql_num_rows($query);

					if($numrows == 0){

						$query = mysql_query("SELECT * FROM users WHERE email='$email'");
						$numrows = mysql_num_rows($query);

						if($numrows == 0){
							$pass = SHA1(md5(md5($password)));
							$date = date("F d, Y");
							if($name){
								move_uploaded_file($tmpname, "avatars/$username.$ext");
								$avatar = "$username.$ext";
							}	
							else
								$avatar = "default01.jpg";
								
								$code = substr(SHA1(rand(11111111111111, 99999999999999)), 2, 25);


							mysql_query("INSERT INTO users VALUES('', '$firstname', '$lastname', '$username', '$email', '$pass', '$avatar', '$bio', '$website', '$youtube', '', '0', '$code', '0', '$date')");

							$webmaster = "technicdelusion@gmail.com";
							$subject = "Activate your account at Blabspot.tk";
							$headers = "From: Jerome<$webmaster>";
							$message = " Welcome to Blabspot $firstname \n\n To Login on our site you must first activate your account. \n\n To do so please follow link below: \n http://www.blabspot.net46.net/activate.php?code=$code \n\n If the link is broken please navigate to www.blabspot.net46.net/activate.php And use the activation code $code \n\n\n NOTE: You will not be able to login if you don't activate your email.";
							
							mail($email, $subject, $message, $headers);

	
							echo "Thank You for registering to Blabspot.TK . To login you must activate your account. We have sent an email to <b>$email</b> with instructions on how to do this. if you have any problems please email the site admin at $webmaster.";



						}
						else
							echo "That email is use by another account. $register";

					}
					else
						echo "That username is already taken. Please Choose another. $register";

				}
			else
				echo"you did not enter a valid email. $register";
		}
		else
			echo"Your passwords did not match. $register";
	}
	else
		echo"You did not fill in all the required feilds. $register";



	
}
else
	echo "$register";

?>

</div>
<?php require("styles/bottom.php") ?>
Member Avatar for iamthwee

You say it doesn't insert anything...

Have you echoed out those variables to check...

oh by the way i have my form in a out side variable

$register = "<form action='register.php' method='post'>

		<table cellspacing='10px'>

		<tr>

			<td></td>

			<td>Forms marked with <font color='red'>*</font> are required.</td>

		</tr>

		<tr>

			<td>First Name: </td>

			<td><input type='text' name='firstname' class='textbox' size='35'><font color='red'>*</font></td>

		</tr>

		<tr>

			<td>Last Name:</td>

			<td><input type='text' name='lastname' class='textbox' size='35'><font color='red'>*</font></td>

		</tr>

		<tr>

			<td>Username:</td>

			<td><input type='text' name='username' class='textbox' size='35'><font color='red'>*</font></td>

		</tr>

		<tr>

			<td>Email:</td>

			<td><input type='text' name='email' class='textbox' size='35'><font color='red'>*</font></td>

		</tr>

		<tr>

			<td>Password:</td>

			<td><input type='password' name='password' class='textbox' size='35'><font color='red'>*</font></td>

		</tr>

		<tr>

			<td>Confirm Password:</td>

			<td><input type='password' name='repassword' class='textbox' size='35'><font color='red'>*</font></td>

		</tr>

		<tr>

			<td>Profile Picture:</td>

			<td><input type='file' name='avatar'></td>

		</tr>

		<tr>

			<td>Website:</td>

			<td><input type='text' name='website' class='textbox' size='35'></td>

		</tr>

		<tr>

			<td>Youtube Username</td>

			<td><input type='text' name='youtube' class='textbox' size='35'></td>

		</tr>

		<tr>

			<td>Bio:</td>

			<td><textarea name='bio' cols='35' rows='5' class='textbox' size='35'></textarea></td>

		</tr>

		<tr>

			<td></td>

			<td><input type='submit' name='submitbtn' value='Register' class='button'></td>

		</tr>

		</table>



		</form> ";

and i do echo the $username.$ext if you look throughout the entire code

Member Avatar for iamthwee

Sorry... Just a quick spot

$firstname && $lastname && $username && $email && $password & $repassword

is that supposed to be && instead of just &

Member Avatar for iamthwee

If it's not that and all your variables are properly sanitized... the only other reason I can think of is that it must be failing on one of the if statements so it never gets to the insert query.

well i do all of this get it all correct it comes up saying you have received an email and i do receive it but it never inserts it too my data base

Member Avatar for iamthwee

^^Hmmm if it sends you an email that would suggest it is getting to that part of the code. So it should execute my_sql insert() statement.

Best bet would be to just test a stand alone mySQL insert with hard coded variables.

i tried it this was the code i used but nothing happend

<?php
require("scripts/connect.php");
mysql_query("INSERT INTO members VALUES('', 'xox', 'xox', 'xox', 'xox', 'xox', 'xox', 'xox', 'xox', 'xox', 'xox', '0', 'xox', '0', 'xox')");
?>

problem solved... i forgot to add the last variable on the end. as i added it on a later date sorry for wasting your time. it was just a stupid error although i wouldn't have noticed it without your help

Member Avatar for iamthwee

Sorry I'm confused you're inserting into members here, but in the previous code you were inserting into users.

[Edit ah cool].

le problem has occurred... it worked when i done it with hard variables but as when i try execute it in the register form it doesn't work.

Member Avatar for iamthwee

OK...

1.I would put specify the column names as well

http://www.w3schools.com/php/php_mysql_insert.asp

INSERT INTO table_name (column1, column2, column3,...)
VALUES (value1, value2, value3,...)

so you know what it is inserting into what and the order.

2. Maybe one of the fields you've defined is an integer but you are inserting a varchar? Although the time/date field is the most likely one to be wrong.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.