I recently created a script for user verification, solved my emailing
issues, and then re-created the script in order to work well with the
new PHP 5 that I installed on my server. After submitting user
information into my creation script, I get the following error from the
page that is suppose to insert the user data into the database, create
a code, then send an email out for verification.
Parse error: parse error, unexpected $end in
c:\wamp\www\thr ead\create\add2 tbl.php on line 31
Below are the files in which I am using:
add2tbl.php
<?php
require "mailfunctions. php";
$username = $_POST['username'];
$md5password2 = md5($_POST['pass2']);
$email = $_POST['email'];
$md5password = md5($_POST['pass']);
if(isset($_POST['username'])) {
if ($md5password == $md5password2) {
$db = dbc();
$code = codegen();
$user = insertuser($use rname, $md5password, $email, $code);
if ($user == FALSE) {
die("There has been an error in adding you to the Database. Please
EMail the admin.");
}
else {
echo "<b>Passwor ds do not match!</b> ";
}
include("/top.html");
$mail = mailauth($usern ame);
if ($mail) {
echo '
<p class = "subtitle">Succ ess! Check your email.</p>';
} else {
echo '
<p class = "subtitle"> We are sorry. The request did not go through
successfully due to an error in the Mail server. Please contact the
Admin.</p>';
}
include("/bottom.html");
}
?>
mailfunctions.p hp
<?php
function dbc() {
mysql_connect(l ocalhost, "root");
mysql_select_db ("ehartwig1" );
return TRUE;
}
function codegen() {
$code = rand(1000000000 0000,9999999999 99999);
return $code;
}
function insertuser($nam e,$md5password, $email,$code) {
$query = "INSERT INTO threadauth (username, password, email,
authcode) VALUES ('{$name}','{$m d5password}','{ $email}', '{$code}') or
return(FALSE)";
$result = mysql_db_query( $query);
return $result;
}
function md5fetcher($nam e) {
$query = mysql_query("SE LECT password FROM threadauth WHERE
username='".$na me."');
$result = mysql_fetch_arr ay($query);
return $result['password'];
}
function mailfetcher($na me) {
$query = mysql_query("SE LECT email FROM threadauth WHERE
username='".$na me."');
$result = mysql_fetch_arr ay($query);
return $result['email'];
}
function codefetcher($na me) {
$query = mysql_query("SE LECT authcode FROM threadauth WHERE
username='".$na me."');
$result = mysql_fetch_arr ay($query);
return $result['authcode'];
}
function codecheck($name , $authcode) {
$code = codefetcher($na me);
if ($code == $authcode) {
return TRUE;
}
else {
return FALSE;
}
}
function mailauth($usern ame) {
$email = mailfetcher($us ername);
$code = codefetcher($us ername);
$message = "
Subscription Request
You have requested to receive a membership. You must follow the
link and insert the code provided in order to activate your account.
Username: {$username}
Activation Code: {$code}
http://www.ehartwig.co m/thread/activate.php?au thcode={$code}& username={$user name}
Thank You.";
mail($recipient , $subject, $message) or return(FALSE);
return(TRUE);
}
?>
How can I solve this problem or what should I do differently?
issues, and then re-created the script in order to work well with the
new PHP 5 that I installed on my server. After submitting user
information into my creation script, I get the following error from the
page that is suppose to insert the user data into the database, create
a code, then send an email out for verification.
Parse error: parse error, unexpected $end in
c:\wamp\www\thr ead\create\add2 tbl.php on line 31
Below are the files in which I am using:
add2tbl.php
<?php
require "mailfunctions. php";
$username = $_POST['username'];
$md5password2 = md5($_POST['pass2']);
$email = $_POST['email'];
$md5password = md5($_POST['pass']);
if(isset($_POST['username'])) {
if ($md5password == $md5password2) {
$db = dbc();
$code = codegen();
$user = insertuser($use rname, $md5password, $email, $code);
if ($user == FALSE) {
die("There has been an error in adding you to the Database. Please
EMail the admin.");
}
else {
echo "<b>Passwor ds do not match!</b> ";
}
include("/top.html");
$mail = mailauth($usern ame);
if ($mail) {
echo '
<p class = "subtitle">Succ ess! Check your email.</p>';
} else {
echo '
<p class = "subtitle"> We are sorry. The request did not go through
successfully due to an error in the Mail server. Please contact the
Admin.</p>';
}
include("/bottom.html");
}
?>
mailfunctions.p hp
<?php
function dbc() {
mysql_connect(l ocalhost, "root");
mysql_select_db ("ehartwig1" );
return TRUE;
}
function codegen() {
$code = rand(1000000000 0000,9999999999 99999);
return $code;
}
function insertuser($nam e,$md5password, $email,$code) {
$query = "INSERT INTO threadauth (username, password, email,
authcode) VALUES ('{$name}','{$m d5password}','{ $email}', '{$code}') or
return(FALSE)";
$result = mysql_db_query( $query);
return $result;
}
function md5fetcher($nam e) {
$query = mysql_query("SE LECT password FROM threadauth WHERE
username='".$na me."');
$result = mysql_fetch_arr ay($query);
return $result['password'];
}
function mailfetcher($na me) {
$query = mysql_query("SE LECT email FROM threadauth WHERE
username='".$na me."');
$result = mysql_fetch_arr ay($query);
return $result['email'];
}
function codefetcher($na me) {
$query = mysql_query("SE LECT authcode FROM threadauth WHERE
username='".$na me."');
$result = mysql_fetch_arr ay($query);
return $result['authcode'];
}
function codecheck($name , $authcode) {
$code = codefetcher($na me);
if ($code == $authcode) {
return TRUE;
}
else {
return FALSE;
}
}
function mailauth($usern ame) {
$email = mailfetcher($us ername);
$code = codefetcher($us ername);
$message = "
Subscription Request
You have requested to receive a membership. You must follow the
link and insert the code provided in order to activate your account.
Username: {$username}
Activation Code: {$code}
http://www.ehartwig.co m/thread/activate.php?au thcode={$code}& username={$user name}
Thank You.";
mail($recipient , $subject, $message) or return(FALSE);
return(TRUE);
}
?>
How can I solve this problem or what should I do differently?
Comment