bylletski Posted March 17, 2013 Share Posted March 17, 2013 Get error: Parse error: syntax error, unexpected T_ELSE in C:\wamp\www\cursetube\scripts\user\register.php on line 130 <?phpinclude 'db.php';$regfname = "";$reglname = "";$regage = "";$regpass1 = "";$regpass2 = "";$regender = "";$regemail1 = "";$regemail2 = "";$regcheckbox = "";$regpage = "";$regaccess = "1";$regdate = date("Y/m/d");if(isset($_POST['regbutton'])) {$regfname = mysql_real_escape_string ($_POST['regfname']);$reglname = mysql_real_escape_string ($_POST['reglname']);$regnickname = mysql_real_escape_string ($_POST['regnickname']);$regage = mysql_real_escape_string ($_POST['regage']);$pass1 = md5 ($_POST['pass1']);$pass2 = md5 ($_POST['pass2']);$regender = mysql_real_escape_string ($_POST['regender']);$regemail1 = mysql_real_escape_string ($_POST['regemail1']);$regemail2 = ($_POST['regemail2']);$regpage = mysql_real_escape_string ($_POST['regpage']);$regcheck = mysql_real_escape_string ($_POST['regcheck']);$regip = $_SERVER['REMOTE_ADDR'];$errors = array();$errors[0] = "Passwords don't match";$errors[1] = "E-Mails don't match";$errors[2] = "You age is under 18.";$errors[3] = "Nickname already exist.";$errors[4] = "Email already exist.";$errors[5] = "Email most be [email protected]";$errors[6] = "You forgot to mark the checkbox.";$errors[7] = "You forgot to fill the textfield for Firstname.";$errors[8] = "You forgot to fill the textfield for Lastname.";$errors[9] = "You forgot to fill the textfield for Nickname.";$errors[10] = "You forgot to fill the textfield for Age.";$errors[11] = "You forgot to fill the textfield for the first password section.";$errors[12] = "You forgot to fill the textfield for the second password section.";$errors[13] = "You forgot to fill the textfield for the first E-mail section.";$errors[14] = "You forgot to fill the textfield for the second E-mail section.";if($pass1 != $pass2) {$errors[] = "Passwords don't match.";}if($regemail1 != $regemail2) {$errors[] = "E-Mails don't match";}if ($regnickname){$sql = "SELECT * FROM `accounts` WHERE `nickname`='".$regnickname."'";$res = mysql_query($sql) or die(mysql_error());if(mysql_num_rows($res) > 0){$errors[] = "Nickname already exist.";}}if ($regemail1){$sql = "SELECT * FROM `accounts` WHERE `email`='".$regemail1."'";$res = mysql_query($sql) or die(mysql_error());if(mysql_num_rows($res) > 0){$errors[] = "E-Mail already exist.";}}if ($regemail1) {$checkregemail1 = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";if(!preg_match($checkregemail1, $regemail1)){$errors[] = "The E-Mail need to be [email protected]";}}if (!$regcheck) {$errors[] = "You forgot to mark the checkbox";}if (!$regfname) {$errors[] = "You forgot to fill the Firstname field.";}if (!$reglname) {$errors[] = "You forgot to fill the Lastname field.";}if (!$regnickname) {$errors[] = "You forgot to fill the Nickname field.";}if (!$regage) {$errors[] = "You forgot to fill the Age field.";}if (!$pass1) {$errors[] = "You forgot to fill the first password field.";}if (!$pass2) {$errors[] = "You forgot to fill the second password field";}if (!$regemail1) {$errors[] = "You forgot to fill the first E-Mail field.";}if (!$regemail2) {$errors[] = "You forgot to fill the second E-Mail field";}if ($regage < 18){$error[] = "You forgot to fill the Age field";}}if(count($errors) > 0){foreach($errors AS $error){echo $error . "<br>\n";} else {mysql_query("INSERT INTO accounts (firstname, lastname, nickname, age, password, gender, email, access, ip, page, date)values ('$regfname', '$reglname', '$regnickname', '$regage', '$pass1', '$regender', '$regemail1', '$regaccess', '$regip', '$regpage', '$regdate')");}}echo '<html><body><center><h3>Register</h3><form method="post" action="?p=register">Firstname<br><input type="text" maxlength="20" name="regfname" value="' . $regfname . '"><br><br>Lastname<br><input type="text" maxlength="20" name="reglname" value="' . $reglname . '"><br><br>Nickname (Max 30 characters)<br><input type="text" maxlength="30" name="regnickname" value="' . $regnickname . '"><br><br>How old are you?<br><input type="text" maxlength="3" name="regage" value="' . $regage . '"><br><br>Password (Max 15 characters)<br><input type="password" maxlength="15" name="pass1"><br><br>Password again (Max 15 characters)<br><input type="password" maxlength="15" name="pass2"><br><br>Man or Woman?<br><select name="regender" value="' . $regender . '"> <option>Man</option><option>Woman</option></select><br><br>Email<br><input type="text" name="regemail1" value="' . $regemail1 . '"><br><br>Email again<br><input type="text" name="regemail2" value="' . $regemail2 . '"><br><br>Do you got a homepage? Maybe facebook?<br><input type="text" name="regpage" value="' . $regpage . '"><br><br>I have read the <a href="?p=rules">RULES </a>and I agree them.<input type="checkbox" name="regcheck"><br><br><input type="submit" name="regbutton" value="Register"></form></center></html></body> ';?> Link to comment https://forums.phpfreaks.com/topic/275781-my-register-script-why-cant-i-use-else-there/ Share on other sites More sharing options...
yomanny Posted March 17, 2013 Share Posted March 17, 2013 if(count($errors) > 0){ foreach($errors AS $error){ echo $error . "<br>\n"; } } // Add this and it'll work else { mysql_query("INSERT INTO accounts (firstname, lastname, nickname, age, password, gender, email, access, ip, page, date) values ('$regfname', '$reglname', '$regnickname', '$regage', '$pass1', '$regender', '$regemail1', '$regaccess', '$regip', '$regpage', '$regdate')"); } } You don't close the if before you start your else, you only close your foreach. - W Link to comment https://forums.phpfreaks.com/topic/275781-my-register-script-why-cant-i-use-else-there/#findComment-1419177 Share on other sites More sharing options...
bylletski Posted March 17, 2013 Author Share Posted March 17, 2013 Thank you very much! Link to comment https://forums.phpfreaks.com/topic/275781-my-register-script-why-cant-i-use-else-there/#findComment-1419195 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.