Jump to content

error pops up when i click the register button within the form.

 

<?php $username = (isset($_POST['username']));$pass1 = (isset($_POST['pass1']));$pass2 = (isset($_POST['pass2']));if (isset( $_POST['Register'] ) ){ echo "login_form.php"; if($pass1 != $pass2);{     header('Location: register.php'); if(strlen($username) > 30)    header('Location: register.php'); $hash = hash('sha256', $pass1); function createSalt(){    $string = md5(uniqid(rand(), true));    return substr($string, 0, 3);}$salt = createSalt();$hash = hash('sha256', $salt . $hash);$dbhost = 'localhost';$dbname = 'Users';$dbuser = 'ash';$dbpass = 'password';$conn = mysql_connect($dbhost, $dbuser, $dbpass);mysql_select_db($dbname, $conn);$username = mysql_real_escape_string($username);$query = "INSERT INTO users ( username, password, salt )        VALUES ( '$username' , '$hash' , '$salt' );";mysql_query($query);mysql_close(); header('Location: login_form.php') ?>
Link to comment
https://linustechtips.com/topic/324771-register-form-syntax-error/
Share on other sites

Link to post
Share on other sites

What error are you getting specifically?

 

Would it be too much to ask for the actual error text?

 

Hold the phone, you're missing a semicolon in the line before the closing php tag.

 

You don't need to close the php tag, by the way, if there is nothing in the file but php. In fact, you shouldn't.

I'm pretty sure the last statement before the closing php tag does not require a semicolon.

Link to post
Share on other sites

give this a go, also indenting like i have makes it much easier to read.

<?php if (isset( $_POST['Register'] ) ){ 	$username = (isset($_POST['username']));	$pass1 = (isset($_POST['pass1']));	$pass2 = (isset($_POST['pass2'])); 	if($pass1 != $pass2);{ 		header('Location: register.php');	}		if(strlen($username) > 30)	{		header('Location: register.php');	}	$hash = hash('sha256', $pass1); 	function createSalt()	{		$string = md5(uniqid(rand(), true));		return substr($string, 0, 3);	}	$salt = createSalt();	$hash = hash('sha256', $salt . $hash);	$dbhost = 'localhost';	$dbname = 'Users';	$dbuser = 'ash';	$dbpass = 'password';	$conn = mysql_connect($dbhost, $dbuser, $dbpass);	mysql_select_db($dbname, $conn);	$username = mysql_real_escape_string($username);	$query = "INSERT INTO users ( username, password, salt )        VALUES ( '$username' , '$hash' , '$salt' );";	mysql_query($query);	mysql_close();   } else 	{	header('Location: login_form.php')	}?>

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×