/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] PHP confirmation script error

Hey guys, I wrote this script a few hours ago, and I was looking for the error, that it keeps throwing out but I cant seem to find it, any help??

[CODE]<?php
//database connection
require (dbconnect.php);

//Get input data

$fname=strip_tags($_POST[‘fullname’]);
$gid=strip_tags($_POST[‘id’]);
$wid=strip_tags($_POST[‘uname’]);
$email=strip_tags($_POST[’email’]);
$pw=strip_tags($_POST[‘pass’]);
$pilot=strip_tags($_POST[‘pilot’]);
$atc=stript_tags($_POST[‘atc’]);
$birth=strip_tags($_POST[‘birth’]);
$errorMessage = “”;

//check to make sure they are not empty
if(empty($fname)) $errorMessage .= “You did not enter your Full Name. <br/>n”;
if(empty($gid)) $errorMessage .=”You did not enter your Gamespy ID. <br/>n”;
if(empty(wid)) $errorMessage .=”You did not enter a Username. <br/>n”;
if(empty($email)) $errorMessage .=”You did not enter an E-mail address. <br/>n”;
if(empty($pw)) $errorMessage .=”You did not enter a Password. <br/>n”;
if(empty($birth)) $errorMessage .=”You did not enter a year of birth. <br/>n”;

//if there was no error, do the rest of the code
if(empty($errorMessage))
{
//get a random 8 character string.
require (randomstring.php);
$confirmationCode = getRandomString();

//add the person and confirmation code into the database
$query = “INSERT INTO ‘users’ (‘fullname’, ‘gid’, ‘uname’, ’email’, ‘birth’, ‘pass’, ‘pilot’, ‘atc’, ‘Random_Key’, ‘Active’)
VALUES (‘$fname’,’$gid’,’$wid’,’$email’,’$birth’,’$pw’,’$pilot’,’$atc’)”;

$result = mysql_query($query) OR die(mysql_error());

//now send them email
$to = “”;
$subject = “”;
$message = “”;
$headers = “”;

/* recipients */
$to = $email;

/* Subjects */
$subject = ‘Site Registration Confirmation’;

/* Message*/
$message = ‘<html>
<head>
<title> Site Registration Confirmation </title>
<body style=”font-family:verdana, arial; font-size: .8em;”>
You’re reciving this email becuase you filled out an appliaction form as a student with Chicago Aviation.
<br/><br/>
If you did not want try to register for an account, you can simply delete this email and no futher action is required.
<br/><br/>
To complete your confirmation and to add you as a student ready for training with Chicago Aviaton, please press the link below: <br/>
<a title=”Confirm Account”
href=”http://www.chicagoaviation.org/confirm.php?c=’.$confirmationCode.'”>http://www.chicagoaviation.org/confrim.php?c=’.$confirmationCode. </a>
<br/><br/>
Thank you and we hope you enjoy your training!<br/><br/>
</body>
</html>

/*To send HTML mail, set the Content-Type Header */
$headers = “MIME-Verson: 1.0rn”;
$headers .= “Content-Type: text/html; charset=iso-8859-1rn”;

/*additional Headers */
$headers .= “From: Chicago Aviation <[email protected]>rn”;

/* and now mail it */
mail($to, $subject, $message, $headers);

//whats going on
echo ‘Click the link in your email to activate your account!’;
}
else
{
echo $errorMessage;
}
?>
[/CODE]

I think it may have something to do with this:

[CODE]//get a random 8 character string.
require (randomstring.php);
$confirmationCode = getRandomString();[/CODE]

but then again I don’t know!

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJul 15.2009 — What is the error "that it keeps throwing out"?
Copy linkTweet thisAlerts:
@UAL225authorJul 15.2009 — Parse error: syntax error, unexpected '<' in /home2/chicagt7/public_html/form.php on line 61 this is what it keeps thowing out, the first error I forgot to add the "$" sign next to [CODE]if(empty(wid)) $errorMessage .="You did not enter a Username. <br/>n";
[/CODE]
I knew it was something that simple.
Copy linkTweet thisAlerts:
@NogDogJul 15.2009 — You left out a quote near the end of the preceding line.

Placing the code in [noparse][code=php]...[/code][/noparse] tags here (or using an editor with syntax highlighting) makes it easier to see:
[code=php]
<?php
//database connection
require (dbconnect.php);

//Get input data

$fname=strip_tags($_POST['fullname']);
$gid=strip_tags($_POST['id']);
$wid=strip_tags($_POST['uname']);
$email=strip_tags($_POST['email']);
$pw=strip_tags($_POST['pass']);
$pilot=strip_tags($_POST['pilot']);
$atc=stript_tags($_POST['atc']);
$birth=strip_tags($_POST['birth']);
$errorMessage = "";

//check to make sure they are not empty
if(empty($fname)) $errorMessage .= "You did not enter your Full Name. <br/>n";
if(empty($gid)) $errorMessage .="You did not enter your Gamespy ID. <br/>n";
if(empty(wid)) $errorMessage .="You did not enter a Username. <br/>n";
if(empty($email)) $errorMessage .="You did not enter an E-mail address. <br/>n";
if(empty($pw)) $errorMessage .="You did not enter a Password. <br/>n";
if(empty($birth)) $errorMessage .="You did not enter a year of birth. <br/>n";

//if there was no error, do the rest of the code
if(empty($errorMessage))
{
//get a random 8 character string.
require (randomstring.php);
$confirmationCode = getRandomString();

//add the person and confirmation code into the database
$query = "INSERT INTO 'users' ('fullname', 'gid', 'uname', 'email', 'birth', 'pass', 'pilot', 'atc', 'Random_Key', 'Active')
VALUES ('$fname','$gid','$wid','$email','$birth','$pw','$pilot','$atc')";

$result = mysql_query($query) OR die(mysql_error());

//now send them email
$to = "";
$subject = "";
$message = "";
$headers = "";

/* recipients */
$to = $email;

/* Subjects */
$subject = 'Site Registration Confirmation';

/* Message*/
$message = '<html>
<head>
<title> Site Registration Confirmation </title>
<body style="font-family:verdana, arial; font-size: .8em;">
You're reciving this email becuase you filled out an appliaction form as a student with Chicago Aviation.
<br/><br/>
If you did not want try to register for an account, you can simply delete this email and no futher action is required.
<br/><br/>
To complete your confirmation and to add you as a student ready for training with Chicago Aviaton, please press the link below: <br/>
<a title="Confirm Account"
href="http://www.chicagoaviation.org/confirm.php?c='.$confirmationCode.'">http://www.chicagoaviation.org/confrim.php?c='.$confirmationCode. </a>
<br/><br/>
Thank you and we hope you enjoy your training!<br/><br/>
</body>
</html>

/*To send HTML mail, set the Content-Type Header */
$headers = "MIME-Verson: 1.0rn";
$headers .= "Content-Type: text/html; charset=iso-8859-1rn";

/*additional Headers */
$headers .= "From: Chicago Aviation <[email protected]>rn";

/* and now mail it */
mail($to, $subject, $message, $headers);

//whats going on
echo 'Click the link in your email to activate your account!';
}
else
{
echo $errorMessage;
}
?>
[/code]
Copy linkTweet thisAlerts:
@UAL225authorJul 15.2009 — Ok never mind all the errors, I got those figured out, now whats stoping me is this error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''users' ('fullname', 'gid', 'uname', 'email', 'birth', 'pass', 'pilot', 'atc', '' at line 1

Here is the fixed code:
[CODE]<?php
//database connection
$dbc = mysql_connect('localhost', 'chicagt7_Tom', 'Boeing07');
if (!dbc)
{
die('Server is off line try back later :' . mysql_error());
}
//selects the MYSQL database
$db_selected = mysql_select_db("chicagt7_Website", $dbc);
if (!$db_selected)
{
die ("cant connect :" . mysql_error());
}

//Get input data

$fname=strip_tags($_POST['fullname']);
$gid=strip_tags($_POST['id']);
$wid=strip_tags($_POST['uname']);
$email=strip_tags($_POST['email']);
$pw=strip_tags($_POST['pass']);
$pilot=strip_tags($_POST['pilot']);
$atc=strip_tags($_POST['atc']);
$birth=strip_tags($_POST['birth']);
$errorMessage = "";

//check to make sure they are not empty
if(empty($fname)) $errorMessage .= "You did not enter your Full Name. <br/>n";
if(empty($gid)) $errorMessage .="You did not enter your Gamespy ID. <br/>n";
if(empty($wid)) $errorMessage .="You did not enter a Username. <br/>n";
if(empty($email)) $errorMessage .="You did not enter an E-mail address. <br/>n";
if(empty($pw)) $errorMessage .="You did not enter a Password. <br/>n";
if(empty($birth)) $errorMessage .="You did not enter a year of birth. <br/>n";

//if there was no error, do the rest of the code
if(empty($errorMessage))
{
//get a random 8 character string.
function getRandomString()
{

$length = 8;

//string of all possiable characters to go into the new password
$passwordRandomString = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789";

//initalize the new password string
$newPW = "";

//seed the random function
srand();

//go through to generate a random password
for($x=0; $x < $length; $x++)
{
$newPW .= substr ($passwordRandomString,rand(0,62),1);
}
return $newPW;
}

$confirmationCode = getRandomString();

//add the person and confirmation code into the database
$query = "INSERT INTO 'users' ('fullname', 'gid', 'uname', 'email', 'birth', 'pass', 'pilot', 'atc', 'Random_Key', 'Active')
VALUES ('$fname','$gid','$wid','$email','$birth','$pw','$pilot','$atc')";

$result = mysql_query($query) OR die(mysql_error());

//now send them email
$to = "";
$subject = "";
$message = "";
$headers = "";

/* recipients */
$to = $email;

/* Subjects */
$subject = 'Site Registration Confirmation';

/* Message*/
$message = '<html>
<head>
<title>Site Registration Confirmation</title>
</head>

<body style="font-family:verdana, arial; font-size: .8em;">
You're receiving this email because you filled out a student registration form on Chicago Aviation.
<br/><br/>
If you did not try to create an account, you can simply delete this email. No further action is required.
<br/><br/>
To complete confirmation and add your registration, please click on the link below:<br>
<a title="Confirm Comment"
href="http://www.chicagoaviation.org/confirm.php?c='.$confirmationCode.'">http://www.chicagoaviation.org/confirm.php?c='.$confirmationCode.'</a>
<br/><br/>
Thank you and we hope you enjoy using Website.com!<br/><br/>

</body>
</html>';

/*To send HTML mail, set the Content-Type Header */
$headers = "MIME-Verson: 1.0rn";
$headers .= "Content-Type: text/html; charset=iso-8859-1rn";

/*additional Headers */
$headers .= "From: Chicago Aviation <[email protected]>rn";

/* and now mail it */
mail($to, $subject, $message, $headers);

//whats going on
echo 'Click the link in your email to activate your account!';
}
else
{
echo $errorMessage;
}
?>
[/CODE]
Copy linkTweet thisAlerts:
@NogDogJul 15.2009 — The MySQL quote character for identifiers (e.g. table names and column names) is the left single quote or "back-tick":
<i>
</i>INSERT INTO <span><code>table_name</code></span> (<span><code>col_a</code></span>, <span><code>col_b</code></span>) VALUES ('string literal', 'uses normal quotes')
Copy linkTweet thisAlerts:
@UAL225authorJul 15.2009 — NogDog, thanks so much, I didn't even realize that all those little tic marks were different. As you can see I am not very good at this. Thanks so much for helping me, now I have this issue:

Column count doesn't match value count at row 1

Does that mean that my table columns (i.e., how many columns) doesn't match how many inputs I have, because I also have an ID which is varchar and auto-incrment as a key?
Copy linkTweet thisAlerts:
@UAL225authorJul 15.2009 — NogDog, don't worry about it, got it all figured out, I didn't have to many columns I had to little info being put in, I forgot to input the ID and the randomstring. Thanks for all the help!!! Truly thanks.
Copy linkTweet thisAlerts:
@NogDogJul 15.2009 — Don't forget to mark this thread "resolved" (if it is) via the "Thread Tools" link near the top of the page.
×

Success!

Help @UAL225 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...