Jump to content

Email activation error


markspec87

Recommended Posts

[code]<?php
include("config.php");

mysql_select_db($dbname)
or die ("Could not select database because ".mysql_error());
// check if the username is taken
$check = "select id from users where username = '".$_POST['username']."';";
$qry = mysql_query($check) or die ("Could not match data because ".mysql_error());
$num_rows = mysql_num_rows($qry);
if ($num_rows != 0) {
echo "Sorry, that username $username is already taken.<br>";
echo "<a href=/signup.php>Try again</a>";
exit;
} else {

$t= time();
// insert the data

$insert = mysql_query("insert into users values ('".$_POST['username']."',
'".$_POST['password']."','','1', '".$_POST['avatar']."', '".$_POST['email']."', '0','$t',

'".$_POST['age']."', '".$_POST['location']."', '".$_POST['clan']."', '".$_POST['website']."',

'".$_POST['about']."')")
or die("Could not insert data because ".mysql_error());

$url='http://www.mysite.com/activate.php?hash='.md5($_POST['password']).’&stamp=’.base64_encode($t);

$to = $_POST['email'];
$subject = "Account Activation";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From: $from";
mail($to,$subject,$message,$headers);


echo "Your user account has been created!<br>";
echo "An activation email has been sent to " .$_POST['email']. "<BR>";

}
?>[/code]

This is my complete signup / email ativation page and it throws the error:

[quote]Parse error: syntax error, unexpected '=' in ....[/quote]

any ideas?
Link to comment
https://forums.phpfreaks.com/topic/28277-email-activation-error/
Share on other sites

[code]<?php
$url='http://www.mysite.com/activate.php?hash='.md5($_POST['password']).’&stamp=’.base64_encode($t);
?>[/code]

Look at ’&stamp=’ (on line 27) - use normal single quotes

Fixed:
[code]<?php
include("config.php");

mysql_select_db($dbname)
or die ("Could not select database because ".mysql_error());
// check if the username is taken
$check = "select id from users where username = '".$_POST['username']."';";
$qry = mysql_query($check) or die ("Could not match data because ".mysql_error());
$num_rows = mysql_num_rows($qry);
if ($num_rows != 0) {
echo "Sorry, that username $username is already taken.<br>";
echo "<a href=/signup.php>Try again</a>";
exit;
} else {

$t= time();
// insert the data

$insert = mysql_query("insert into users values ('".$_POST['username']."',
'".$_POST['password']."','','1', '".$_POST['avatar']."', '".$_POST['email']."', '0','$t',

'".$_POST['age']."', '".$_POST['location']."', '".$_POST['clan']."', '".$_POST['website']."',

'".$_POST['about']."')")
or die("Could not insert data because ".mysql_error());

$url='http://www.mysite.com/activate.php?hash='.md5($_POST['password']).'&stamp='.base64_encode($t);

$to = $_POST['email'];
$subject = "Account Activation";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From: $from";
mail($to,$subject,$message,$headers);


echo "Your user account has been created!<br>";
echo "An activation email has been sent to " .$_POST['email']. "<BR>";

}
?>[/code]

Archived

This topic is now archived and is closed to further replies.

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