email validation url problem.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mmc01ms
Forum Commoner
Posts: 97
Joined: Wed Dec 01, 2004 3:33 am
Location: Nottingham, UK

email validation url problem.

Post by mmc01ms »

Hey guys i've created a register form which sends a validation email to the user. Everything works fine except the url link which it gives to click doesn't allow the user to click it. it appears but not as a url just blue static text as part of the message. However i have given it the <a href> to make it a url. code below any ideas?

Code: Select all

<? function send_validation_email()
	{
		$firstname = $_POST['firstName'];
		$surname = $_POST['lastName'];
		$username = $_POST['username'];
		
		echo $firstname
			." "
			. $surname 
			. ", You have succesfully become a customer of Funky Monkey Records. You will recieve a validation e-mail so you can activiate your account.<br><br>
						";
		$link_id = db_connect();
		$query= mysql_query("Select customer_id from customers where username = '$username'");
		$row = mysql_fetch_array($query);
		$customer_id = $row['customer_id'];
		
		$emailMessage = "<html><body>Dear ". $firstname . " " . $surname. "<br><br>
				You have registred an account at Funky Monkey Records. In order to complete registration you have to click this activation
				link:<br><a href="validate.php?page=validate&customer_id=" . $customer_id . "">validate.php?page=validation&customer_id=" . $customer_id . "</a></body></html>";
		
		$to = $_POST['email'];
		$from = "mmc01ms@hotmail.com";
		$message= $emailMessage;
		$subject = "Succesfully registred as ". $username;
		$headers = "From: $from";
		if(mail($to,$subject,$message,$headers)){
		} else{
			echo"<br><br>Failed sending an email";
			
		}
	}

?>

message body of email is as followed:

Code: Select all

Dear manpreet Smith

You have registred an account at Funky Monkey Records. In order to complete registration you have to click this activation link:
validate.php?page=validation&amp;customer_id=123577
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Does the mail client allow html? Its not just displaying the html code, so it must be doing something with the html code. You will also probably want the full URL in the link as at the moment it wont go to your site as its a local link - this might be known in some clients and so doesnt show the link as its invalid.
mmc01ms
Forum Commoner
Posts: 97
Joined: Wed Dec 01, 2004 3:33 am
Location: Nottingham, UK

Post by mmc01ms »

thanks for the speedy reply however i've tried what you said and no joy. Also i've appended my code to allow html code. Hotmail does allow html markup. I've also inlcuded what markup hotmail returns below. Any other ideas?

Code: Select all

<? function send_validation_email()
	{
		$firstname = $_POST['firstName'];
		$surname = $_POST['lastName'];
		$username = $_POST['username'];
		
		echo $firstname
			." "
			. $surname 
			. ", You have succesfully become a customer of Funky Monkey Records. You will recieve a validation e-mail so you can activiate your account.<br><br>
						";
			$link_id = db_connect();
		$query= mysql_query("Select customer_id from customers where username = '$username'");
		$row = mysql_fetch_array($query);
		$customer_id = $row['customer_id'];
		
		$emailMessage = "<html><body>Dear ". $firstname . " " . $surname. "<br><br>
				You have registred an account at Funky Monkey Records. In order to complete registration you have to click this activation
				link:<br><a href="http://146.227.22.22/~php32/validate.php?page=validate&customer_id=".$customer_id."">http://146.227.22.22/~php32/validate.php?page=validation&customer_id=".$customer_id."</a></body></html>";
		
		$to = $_POST['email'];
		$from = "mmc01ms@hotmail.com";
		$message= $emailMessage;
		$subject = "Succesfully registred as ". $username;
		$headers = "MIME-Version: 1.0\r\n";
		$headers.= "Content-type: text/html;";
		$headers.= "charset=iso-8859-1\r\n";
		$headers.= "From: $from \r\n";
		if(mail($to,$subject,$message,$headers)){
		} else{
			echo"<br><br>Failed sending an email";
			
		}
	}
	
?>
hotmail returns:

Code: Select all

&lt;div&gt;
Dear manpreet Smith&lt;br&gt;&lt;br&gt;
				You have registred an account at Funky Monkey Records. In order to complete registration you have to click this activation
				link:&lt;br&gt;&lt;a&gt;http://146.227.22.22/~php32/validate.php?page=validation&amp;customer_id=123579&lt;/a&gt;

&lt;font color="#000000"&gt;&lt;/div&gt;
Post Reply