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 = "webmaster@clan.com";
$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
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 = "webmaster@clan.com";
$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]
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.