I have a php script :) Basically users signup receive an email and click on an activation link. When they click on the activation link it takes them to the activate.php page and all is done. The problem the link in the email they receive looks like

Hello username, Now here is your login info:

username: computing
password: computing

The next step is to click on this link to activate your account: CLICK HERE

You can see in the last line above that the name of there website is joined to the activate.php page the link is supposed to take them to. So im guessing my error is not so bad and I'm just missing forward slash or something like that. Anyway I think the problem comes from the code below. I have kept the code short as possible.

<?

// send email
$myname = $contact_name;
$myemail = $contact_email;

$contactname = $signup[fname];
$contactemail = $signup[email];
$message = "Hello ".$signup[fname].",<BR>".
"Get ready to start getting the hits you deserve. Now here is your login info:<BR>     <BR>".
"username: ".$signup[username]."<BR>".
"password: ".$signup[password]."<BR><BR>".
"<B>The next step is to click on this link to activate your account:<a href=".$siteUrl."activate.php?username=".$signup[username].">CLICK HERE</a></b>";
$subject = $title;

$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ".$myname." <".$myemail.">\r\n";
$headers .= "To: ".$contactemail." <".$contactemail.">\r\n";
$headers .= "Reply-To: ".$myname." <".$myemail.">\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-MSMail-Priority: High\r\n";
$headers .= "X-Mailer: Just My Server";

mail($contactemail, $subject, $message, $headers);
$signup[username] = "";
?>

If anyone can shed some light on this it would be good. Thought I would just mention I am using PHP 5.3 I think myself the problem comes from href=".$siteUrl."activate.php?username=".$signup[username].">CLICK HERE"; $subject = $title;

But I need some valid input :) from some one who knows.

有帮助吗?

解决方案 2

I noticed when you assign your link you used .$siteUrl. have you actually set that variable?

Also since you would be comming from an outside source (e-mail hosting website) it would work just as fine to "hard-code" your link as your full website address. Ex:

<a href="http://www.yourwebsite.com/yourdirectories/activate.php?username=".$signup[username].">Click Here</a>

So a value of your message value could be.

$message = "Hello ".$signup[fname].",<BR>".
"Get ready to start getting the hits you deserve. Now here is your login info:<BR>     <BR>".
"username: ".$signup[username]."<BR>".
"password: ".$signup[password]."<BR><BR>".
"<B>The next step is to click on this link to activate your account:<a href='http://www.yourwebsite.comactivate.php?username=".$signup[username]."'>CLICK HERE</a></b>";

You shouldn't have a problem with the double slashes but if you have a problem with those you can use:

$message = "Hello ".$signup[fname].",<BR>".
"Get ready to start getting the hits you deserve. Now here is your login info:<BR>     <BR>".
"username: ".$signup[username]."<BR>".
"password: ".$signup[password]."<BR><BR>".
"<B>The next step is to click on this link to activate your account:<a  href='http:/"."/www.yourwebsite.com/activate.php?username=".$signup[username]."'>CLICK HERE</a></b>";

其他提示

You need a space between "a" and "href" in your message.

Also, all modern email clients automatically turn URLs into links, so it probably isn't necessary to use an href tag at all.

Because it's inside the string "s you need to escape them or use single-quotes.

Here's a fixed version:

$message = "Hello ".$signup[fname].",<br>".
  "Get ready to start getting the hits you deserve. Now here is your login info:<br>     <br>".
  "username: ".$signup[username]."<br>".
  "password: ".$signup[password]."<br><br>".
  "<b>The next step is to click on this link to activate your account: 
  <a href='".$siteUrl."activate.php?username=".$signup[username].'>CLICK HERE</a></b>";
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top