/    Sign up×
Community /Pin to ProfileBookmark

Good morning, all. I’m sort of new at php and have been teaching myself with online tutorials and such. I’m getting the hang of it so far, but last night I ran into a problem that I can’t seem to resolve. Here is the code below:

[CODE]if ( (strlen($getemail) >= 7) && (strstr($getemail), ‘@’) && (strstr($getemail), ‘.’)){
require(“connect.php”);

$query = mysql_query(“SELECT * FROM members WHERE username=’$getuser'”);
$numrows = mysql_num_rows($query);

if ($numrows == 0){
$query = mysql_query(“SELECT * FROM members WHERE email=’$getemail'”);
$numrows = mysql_num_rows($query);
if ($numrows == 0){

$password = md5(md5(“[salt]”.$password.”[salt]”));
$date = date(‘F d, Y’);
$code = md5(rand());

mysql_query (“INSERT INTO members VALUES (
”, ‘$getuser’, ‘$password’, ‘$getemail’, ”, ‘$date’, ‘0’, ‘$code’, ‘$getfirstname’, ‘$getlastname’, ‘$lastloginip’, ‘$getbirthmonth’, ‘$getbirthday’, $getbirthyear’, ‘$getgender’
)”)

$query = mysql_query(“SELECT * FROM members WHERE username=’$getuser'”)

}
else {
$errormsg = “There is already a user with that email address.”;
}
}
else {
$errormsg = “There is already a user with that username.”;
}

mysql_close();
}
else {
$errormsg = “You must enter a valid email address to register.”
}
[/CODE]

The error I’m receiving is:

“Parse error: syntax error, unexpected ‘,’ in /[address here]/register.php on line 35”

Line 35 is the very first line in the given code. I don’t know what it’s trying to tell me.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMay 03.2012 — [code=php]
if ( ( strlen($getemail) >= 7 ) && ( strstr($getemail, '@') ) && ( strstr($getemail, '.') ) ){
[/code]
Copy linkTweet thisAlerts:
@TrancienceauthorMay 03.2012 — Thanks, NogDog! That fixed it! There were about 3 more syntax errors after that, but I was able to find them. I ran the code and another problem occurred that I'm unaware of. Whenever I fill out the form and click the submit button, I'm taken to a completely blank version of register.php and I don't know why it doesn't take me back to the form.

[code=php]<?php

error_reporting(E_ALL ^ E_NOTICE);

?>

<html>

<head>
<title>XC - Registration</title>
</head>

<body>

<?php

if ($_POST['submitbtn']){
$getuser = $_POST['user'];
$getemail = $_POST['email'];
$getpass = $_POST['pass'];
$getverifypass = $_POST['verifypass'];
$lastloginip = $_SERVER['REMOTE_ADDR'];
$getfirstname = $POST['firstname'];
$getlastname = $_POST['lastname'];
$getbirthmonth = $_POST['birthmonth'];
$getbirthday = $_POST['birthday'];
$getbirthyear = $_POST['birthyear'];
$getgender = $_POST['gender'];

if ( $getuser){
if ( $getemail){
if ( $getpass){
if ( $getverifypass){
if ( $getpass === $getverifypass){
if ( ( strlen($getemail) >= 7 ) && ( strstr($getemail, '@') ) && ( strstr($getemail, '.') ) ){ require('connect.php');

$query = mysql_query("SELECT * FROM members WHERE username='$getuser'");
$numrows = mysql_num_rows($query);

if ($numrows == 0){
$query = mysql_query("SELECT * FROM members WHERE email='$getemail'");
$numrows = mysql_num_rows($query);
if ($numrows == 0){

$password = md5(md5("salt".$getpass."salt"));
$date = date('F d, Y');
$code = md5(rand());

mysql_query ("INSERT INTO members VALUES (
'', '$getuser', '$password', '$getemail', '', '$date', '0', '$code', '$getfirstname', '$getlastname', '$lastloginip', '$getbirthmonth', '$getbirthday', $getbirthyear', '$getgender'
)");

$query = mysql_query("SELECT * FROM members WHERE username='$getuser'");
$numrows = mysql_num_rows($query);
if ($numrows == 1){

$site = 'http://localhost';
$webmaster = 'XC Admin <[email protected]>';
$headers = 'From: $webmaster';
$subject = 'Trancience: Activate your account';
$message = 'Thanks for registering. Click the link below to activate your account. n $site/activate.php?user=$getuser&code=$code n You must activate your account to login.';

if (mail($getemail, $subject, $message, $headers)){

$errormsg = "You have been registered. You must activate your account with the activation link sent to <b>$getemail</b>.";
$getuser = '';
$getemail = '';

}
else
$errormsg = "An error has occurred. Your activation email was not sent.";

}
else
$errormsg = "An error has occurred. Your account was not created.";

}
else
$errormsg = "There is already a user with that email address.";

}
else
$errormsg = "There is already a user with that username.";


mysql_close();
}
else
$errormsg = "You must enter a valid email address to register.";

}
else
$errormsg = "Your passwords did not match.";

}
else
$errormsg = "You must verify your password to register.";

}
else
$errormsg = "You must enter a password to register.";

}
else
$errormsg = "You must enter your email to register.";

}
else
$errormsg = "You must enter your username to register.";
}
else


$form = "<form action='register.php' method='post'><fieldset><b><legend>Player Information</legend></b>
<table>
<tr>
<td colspan='2'><font color='red'>$errormsg</font></td>
</tr>
<tr>
<td>First Name:</td>
<td><input type='text' name='firstname' value='$getfirstname' /></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text' name='lastname' value='$getlastname' /></td>
</tr>
<tr>
<td>Gender:</td>
<td><select name='gender' value='$getgender'>
<option selected value='male'>Male</option>
<option value='female'>Female</option></td>
</select>
</tr>
<tr>
<td>Date of Birth:</td>
<td>
<select name='birthmonth' value='Month'>
<option selected value='January'>January</option>
<option value='February'> February</option>
<option value='March'>March</option>
<option value='April'>April</option>
<option value='May'>May</option>
<option value='June'>June</option>
<option value='July'>July</option>
<option value='August'>August</option>
<option value='September'>September</option>
<option value='October'>October</option>
<option value='November'>November</option>
<option value='December'>December</option>
</select>
<select name='birthday'>
<option selected value='01'>01</option>
<option value='02'>02</option>
<option value='03'>03</option>
<option value='04'>04</option>
<option value='05'>05</option>
<option value='06'>06</option>
<option value='07'>07</option>
<option value='08'>08</option>
<option value='09'>09</option>
<option value='10'>10</option>
<option value='11'>11</option>
<option value='12'>12</option>
<option value='13'>13</option>
<option value='14'>14</option>
<option value='15'>15</option>
<option value='16'>16</option>
<option value='17'>17</option>
<option value='18'>18</option>
<option value='19'>19</option>
<option value='20'>20</option>
<option value='21'>21</option>
<option value='22'>22</option>
<option value='23'>23</option>
<option value='24'>24</option>
<option value='25'>25</option>
<option value='26'>26</option>
<option value='27'>27</option>
<option value='28'>28</option>
<option value='29'>29</option>
<option value='30'>30</option>
<option value='31'>31</option>
</select>
<input maxlength=4 name='birthyear' value='$getbirthyear' size=4> Format (month dd, yyyy)
<tr>
<td>Username:</td>
<td><input type='text' name='user' value='$getuser' /></td>
</tr>
<tr>
<td>Email:</td>
<td><input type='text' name='email' value='$getemail' /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='pass' value='$getpass' /></td>
</tr>
<tr>
<td>Verify:</td>
<td><input type='password' name='verifypass' value='$getverifypass' /></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='submitbtn' value='Register' /></td>
</tr>

</table></fieldset>
</form>";

echo $form;



?>
</body>
</html>[/code]
Copy linkTweet thisAlerts:
@PHPNewbie1234May 04.2012 — This is because your form action takes you to register.php that is why. What do you mean it does not take you back to the form?
×

Success!

Help @Trancience 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.20,
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,
)...