Page 1 of 1

Register and login(email activation extension)

Posted: Thu Mar 15, 2012 8:26 pm
by Robbedoesie
Hello,
i get an error 'Parse error: syntax error, unexpected $end in C:\wamp\www\gallery\inc\user.inc.php on line 57'.

This is the user.inc.php
<?php
//bestaat de gebruikersnaam in de database
function user_exists($user){
	$user = mysql_real_escape_string($user);
	$total = mysql_query("SELECT COUNT('user_id') FROM `user_system` WHERE `user_name` = '{$user}'");
	return (mysql_result($total, 0) == '1') ? true : false;
}
//is de gebruikersnaam en paswoord correct
function valid_credentials($user, $pass){
	$user = mysql_real_escape_string($user);
	$pass = mysql_real_escape_string($pass);
	
	$total = mysql_query("SELECT COUNT('user_id') FROM `user_system` WHERE `user_name` = '{$user}' AND `user_password` = '{$user}'");
	
	return (mysql_result($total, 0) == '1') ? true : false;
}
function is_active($user){
	$user = mysql_real_escpe_string($user);
	
	$sql = "SELECT
			COUNT(`user_activations`. `user_id`)
			FROM `users`
			INNER JOIN `user_activations`
			ON `users`, `user_id` = `user_activations`,`user_id`
			WHERE `users`,`user_name` = '{$user}'";
			
	$result = mysql_query($sql);
	return (mysql_result($result, 0) == '0') ? true : false;
}
function activate_account($aid){
		$aid = mysql_real_escape_string($aid);
		
		mysql_query("DELETE FROM `user_activations` WHERE `activations_code` = '{$aid}'");
		
}
//voegt een gebruiker toe aan de database
function add_user($user, $email, $pass){
	$user  = mysql_real_escape_string(htmlentities($user));
	$email = mysql_real_escape_string($email);
	$pass  = sha1($pass);
	
	$charset = array_flip(array_merge(range('a', 'z'), range('A', 'Z'), range(0, 9)));
	$aid = implode('', array_rand($charset, 10));
	
	$body = <<<EMAIL
	Hallo,
	dank voor het registreren, voordat je gaat inloggen is het nodig dat je je account gaat activeren.
	omdat de doen kan je gewoon op deze link klikken, http://www.robcnossen.nl/activate.php?aid={$aid}
	EMAIL;
mail($email, 'je nieuwe account in mijnwebsite.nl', $body, 'From: mijnemail@email.nl');	
	
	mysql_query("INSERT INTO `user_system` (`user_name`, `user_password`, `user_email`) VALUES ('{$user}', '{$pass}', '{$email}')");
	$user_id = mysql_insert_id();
	mysql_query("INSERT INTO `user_activations` (`user_id`, `activations_code`) VALUES ({$user_id}, '{$aid}')");
}

?>
If i delete the $body = <<<EMAIL EMAIL; part the error is gone, but then of course it is useless. I can't find how i can get this error away.
Hopefully somebody can help me?

Thanks

Re: Register and login(email activation extension)

Posted: Fri Mar 16, 2012 12:02 am
by Temor
Initially I had no idea what was wrong but I watched Jacek's tutorial and he mentioned that the end EMAIL; thing needs to be to the left. It can't be indented. You need to remove all the whitespace before it or else it won't work.

Re: Register and login(email activation extension)

Posted: Fri Mar 16, 2012 9:28 pm
by Robbedoesie
Thanks Temor, i did'nt came up with that idea.