Jump to content

user validation via email


freemancomputer

Recommended Posts

I am working on user validation through email and I am having some problems with it. I can get it to work but it gives me probloms some times.

 

This is the link that is sent to the users after they sign up

mydomain/confirm.php?id=".$id."&userkey=".$userkey

 

and this is what i have for the confirm page

 

<?php

//connection info

	$userquery = mysql_query("SELECT * FROM user");
	$active=mysql_result($userquery,  "active");
	$userid=mysql_result($userquery,  "id");
	$userkey=mysql_result($userquery, "userkey");


	if ($active == 1) {

		printf("This account has already been activated");
		echo "<br />";
	}

	elseif($userkey != $posteduserkey){
	printf("We are sorry but the data offered does not match data listed, plese contact system admin.");
	}

	else{
	$query="UPDATE user SET active='1' WHERE id='$id'";

	mysql_query($query) or die (mysql_error());  


	echo "You have activated your account";

	?>
	<div align="center"><br /><a href="login.php" class="nav">Back to the log in page</a></div>

	<?php
	}

?>

This is the fun part. I checked that the id and userkey are correct in the link, and they are. I then replaced the & in the link with & it works in gmail but not yahoo email address. I'm not sure where else to look.

 

Thanks in advance

 

Link to comment
Share on other sites

Hoold on there. This is how you use mysql_result:

string mysql_result ( resource $result , int $row [, mixed $field = 0 ] )

Field name is the third argument, not the second.  You're also getting the first row in the user table, not the row for the user you're trying to check... come on now.

 

<?php

//connection info

	$userquery = mysql_query("SELECT * FROM user WHERE id='$id'") or die(mysql_error());
	if(mysql_num_rows($userquery) == 0) {
		printf("Could not find the information for this user.");
		exit;
	}

	$active=mysql_result($userquery, 0, "active");
	$userid=mysql_result($userquery, 0, "id");
	$userkey=mysql_result($userquery, 0, "userkey");


	if ($active == 1) {

		printf("This account has already been activated");
		echo "<br />";
	}

	elseif($userkey != $posteduserkey){
	printf("We are sorry but the data offered does not match data listed, plese contact system admin.");
	}

	else{
	$query="UPDATE user SET active='1' WHERE id='$id'";

	mysql_query($query) or die (mysql_error());  


	echo "You have activated your account";

	?>
	<div align="center"><br /><a href="login.php" class="nav">Back to the log in page</a></div>

	<?php
	}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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