Register and login(email activation extension)

Post here is you are having problems with any of the tutorials.
Post Reply
User avatar
Robbedoesie
Posts: 97
Joined: Thu May 19, 2011 7:37 pm
Location: Enkhuizen, Holland

Register and login(email activation extension)

Post 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
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: Register and login(email activation extension)

Post 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.
User avatar
Robbedoesie
Posts: 97
Joined: Thu May 19, 2011 7:37 pm
Location: Enkhuizen, Holland

Re: Register and login(email activation extension)

Post by Robbedoesie »

Thanks Temor, i did'nt came up with that idea.
Post Reply