im a newbie php developer...

i've tried sending an email n receiving the confirmation back for activating the users...

here is the email sending code :

if($res)
{
	echo "record added";
	$to = $mail;
	$sub = "Confirm Mail From LeLys";
	$header = "from: admin<support@domain.org>";
	
	$message = "confirm link \r\n";
	$message.= "click to activete your account";
	$message.= "";
	
	$sending = mail($to,$sub,$message,$header);
	
		if($sending)
			echo ("email comfirm");
		else
			echo("email not sent");

}

here is the Confirmation Page :

$passkey = $_GET['key'];
$sql1 = "SELECT * FROM temp_db WHERE code='$passkey'";
$result1 = mysql_query($sql1);

if($result1)
{
	// Count how many row has this passkey
	$count = mysql_num_rows($result1);
	
	// if found this passkey in our database, retrieve data from table "temp_members_db"	
	if($count == 1)
	{
		$rows = mysql_fetch_array($result1);
		$a = $rows['fname'];
		$b = $rows['mname'];
		$c = $rows['lname'];
		$d = $rows['dob'];
		$e = $rows['gender'];
		$f = $rows['email'];
		$g = $rows['country'];
		$h = $rows['phno'];
		$i = $rows['mobile'];
		$j = $rows['userid'];
		$k = $rows['password'];
		$l = $rows['mti'];
		$m = = $rows['rtime'];
		
		$sql2 = "INSERT INTO regd_db(fname,mname,lname,dob,gender,email,country,phno,mobile,userid,password,mti,rtime)
				 VALUES('$a','$b','$c','$d','$e','$f','$g','$h','$i','$j','$k','$l','$m')";
		$result2 = mysql_query($sql2);
	}
	// if not found passkey, display message "Wrong Confirmation code"
	else
		echo "Wrong confirmation code";
	// if successfully moved data from table"temp" to table "registered" display"Your account has been activated"
	if($result2)
	{
		echo "You hav Been Activated.. please log in";
		
		$sql3 = "DELETE FROM temp_db WHERE code='$passkey'";
		$result3 = mysql_query($sql3) or die("Cud not delete temp files");
	}
}

On clicking the link in my email, i get a BLANK confirmation page...

wat is the prob.. ?

need help

Dani AI

Generated

Good catch by — a stray = in the confirmation script will produce a parse/fatal error and the browser just shows a blank page. fixed that and the flow started working, but a few extra checks and small improvements will make the confirmation flow more robust and safe for future readers.

Turn on full error reporting while developing so PHP shows the actual error instead of a blank page:

ini_set('display_errors', 1);
error_reporting(E_ALL);

Also check the server/PHP error log when display is off (production). For every database call verify the result and surface DB errors during debugging, for example:

$result1 = mysql_query($sql1);
if (! $result1) { die('DB error: ' . mysql_error()); }

This makes it clear when a query fails and why. Use mysql_fetch_assoc() if you want array keys by column name, and avoid assuming numeric or associative indexes interchangeably.

A few production-minded points to prevent subtle bugs and hard-to-find problems:

  • Never trust raw $_GET values: validate length and allowed characters and use prepared statements (PDO or MySQLi) instead of old mysql_* calls to prevent SQL injection and to work on modern PHP versions.
  • Don’t store passwords in plain text. Use password_hash() and password_verify() (or an appropriate hashing scheme) instead.
  • When you send an activation link as HTML, include proper headers and a safe From header, and urlencode the token. Example headers for HTML mail:
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$headers .= "From: Admin <support@yourdomain.com>\r\n";
  • If using InnoDB, wrap the insert-and-delete activation steps in a transaction so a failure doesn’t leave inconsistent state. After successful activation, redirect to a friendly page rather than just echoing text to avoid repeated activations.

These steps will make debugging easier and the whole process safer and more maintainable for anyone who finds this thread later.

Recommended Answers

All 8 Replies

im a newbie php developer...

i've tried sending an email n receiving the confirmation back for activating the users...

here is the email sending code :

if($res)
{
	echo "record added";
	$to = $mail;
	$sub = "Confirm Mail From LeLys";
	$header = "from: admin<support@domain.org>";
	
	$message = "confirm link \r\n";
	$message.= "click to activete your account";
	$message.= "";
	
	$sending = mail($to,$sub,$message,$header);
	
		if($sending)
			echo ("email comfirm");
		else
			echo("email not sent");

}

here is the Confirmation Page :

$passkey = $_GET['key'];
$sql1 = "SELECT * FROM temp_db WHERE code='$passkey'";
$result1 = mysql_query($sql1);

if($result1)
{
	// Count how many row has this passkey
	$count = mysql_num_rows($result1);
	
	// if found this passkey in our database, retrieve data from table "temp_members_db"	
	if($count == 1)
	{
		$rows = mysql_fetch_array($result1);
		$a = $rows['fname'];
		$b = $rows['mname'];
		$c = $rows['lname'];
		$d = $rows['dob'];
		$e = $rows['gender'];
		$f = $rows['email'];
		$g = $rows['country'];
		$h = $rows['phno'];
		$i = $rows['mobile'];
		$j = $rows['userid'];
		$k = $rows['password'];
		$l = $rows['mti'];
		$m = = $rows['rtime'];
		
		$sql2 = "INSERT INTO regd_db(fname,mname,lname,dob,gender,email,country,phno,mobile,userid,password,mti,rtime)
				 VALUES('$a','$b','$c','$d','$e','$f','$g','$h','$i','$j','$k','$l','$m')";
		$result2 = mysql_query($sql2);
	}
	// if not found passkey, display message "Wrong Confirmation code"
	else
		echo "Wrong confirmation code";
	// if successfully moved data from table"temp" to table "registered" display"Your account has been activated"
	if($result2)
	{
		echo "You hav Been Activated.. please log in";
		
		$sql3 = "DELETE FROM temp_db WHERE code='$passkey'";
		$result3 = mysql_query($sql3) or die("Cud not delete temp files");
	}
}

On clicking the link in my email, i get a BLANK confirmation page...

wat is the prob.. ?

need help

How about putting a else statement here

if($result2)
	{
		echo "You hav Been Activated.. please log in";
		
		$sql3 = "DELETE FROM temp_db WHERE code='$passkey'";
		$result3 = mysql_query($sql3) or die("Cud not delete temp files");
	}else
{
         echo 'problems found';
}

let see if which will it print.

hi ivatanako

tried wat u said.. but still no hope..

still getting te same blank page...

Usually all output disappears from your browser if you have an error in your code, and error_reporting is set to E_ALL & E_NOTICE in your php.ini file.
In this case, i think your error, is that you are using trying to access array items using associative indices, when your array only has number indices because you used mysql_fetch_array.

Therefore if you use mysql_fetch_array($result1), then access your array items as $rows[0], $rows[1], ...
If you use mysql_fetch_assoc($result1), then access your array items as $rows, $rows, ...

Try that !

hey wilch..

i've tried that assoc fetch, but still get the same blank page..

i saw my php.ini file..

error_reporting
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED

this is wat i found in it...

does this mean anything related to my prob.. ? coz i dont know..

well, then that's not the problem for you, but ofr me - i once experienced it on that part.

Anyway, i think i see where the problem is. Line 26, there's an extra = sign.
Remove it !

Dude...

thanks man... its working now...

but... need some tuning help...

You hav Been Activated.. please log in
Cud not insert into regd user

this is the output im getting...

but the database has been updated into regd user....

hey Wilch...

thanks... the "=" sign was the prob i think...

i found, why the above posted error was coming...

i stupidly echo'd it...

thanks again.. i myself did not read my code fully,

Cool buddy !
Plus the gratitude is even better, if you Add To Their Reputation, the thread they helped you solve.

:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.