Jump to content

Register Script VALUES not inserting


Tom10

Recommended Posts

Hello, So i'm making a register script and the values are not inserting here is my script.

if(isset($_POST['register'])) {
	
	$username = $_POST['username'];
	$password = $_POST['password'];
	$cpassword = $_POST['cpassword'];

	$username = htmlentities($username, ENT_QUOTES);
	$password = htmlentities($password, ENT_QUOTES);
	$cpassword = htmlentities($cpassword, ENT_QUOTES);

	$username = htmlspecialchars($username, ENT_QUOTES);
	$password = htmlspecialchars($password, ENT_QUOTES);
	$cpassword = htmlspecialchars($cpassword, ENT_QUOTES);

	$username = mysqli_real_escape_string($con, $username);
	$password = mysqli_real_escape_string($con, $password);
	$cpassword = mysqli_real_escape_string($con, $cpassword);

	$username = strip_tags($username);
	$password = strip_tags($password);
	$cpassword = strip_tags($cpassword);

	$cpassword = hash('ripemd128', $cpassword);

	$denymsg = "<h3>The username or password you have entered has been rejected. Check their are not illeagal characters, ie. 
	code, special characters etc.
	</h3>";

	if(preg_match("#[^\w\?\&\=\.]#", $username)) {

		echo $denymsg;

		die();

	} else {


	}

	if(preg_match("#[^\w\?\&\=\.]#", $password)) {

		echo $denymsg;

	} else {


	}

	if($password !== $_POST['cpassword']) {

		die("Passwords do not match!");
	}

	if(!$username OR !$password) {

		die("Make sure you have entered a username and password!");
	}

	$sql = "INSERT INTO `users` (username, password) VALUES ('$username', '$cpassword')";

	if($sql === TRUE) {

		echo "Your account (".$username.") has been created!";

	} else {

		echo "Your account (".$username.") could not be created. ";

		echo "<br> <br>
		".var_dump($sql)."
		 ";
	}

}

I do not get any errors, but here is the result of the variable dump

Your account (user) could not be created. string(92) "INSERT INTO `users` (username, password) VALUES ('user', '602cb6acf8f1d5a8c402bc6b9505730f')" 
Link to comment
https://forums.phpfreaks.com/topic/294643-register-script-values-not-inserting/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.