jd2007 Posted July 14, 2007 Share Posted July 14, 2007 <?php /*Use of Sessions*/ if(!session_id()) session_start(); header("Cache-control: private"); //avoid an IE6 bug (keep this line on top of the page) //function validateEmail($email) //{ // return ereg("^[a-zA-Z0-9\_\-\.]+@[a-zA-Z]+\.[a-zA-Z\.\-]+$", $email); //} if (isset($_POST['nickname']) && isset($_POST['password']) && isset($_POST['cpass']) && isset($_POST['email']) { if (isset($_POST['password']) == isset($_POST['cpass'])) { if (ereg("^[a-zA-Z0-9\_\-\.]+@[a-zA-Z]+\.[a-zA-Z\.\-]+$",($_POST['email']))) { /*Connection to database logindb using your login name and password*/ $db=mysql_connect('localhost','root') or die(mysql_error()); mysql_select_db('Vote'); /*additional data checking and striping*/ $_POST['nickname']=mysql_real_escape_string(strip_tags(trim($_POST['login']))); $_POST['cpass']=mysql_real_escape_string(strip_tags(trim($_POST['cpass']))); mysql_query("INSERT INTO Users SET nickname='{$_POST['nickname']}',cpass='{$_POST['cpass']}'",$db); if(mysql_affected_rows() > 0) { $_SESSION['nickname'] = $_POST['nickname']; $to = isset($_POST['email']); $subject = 'Voting User Confirmation'; $headers = "MIME-Version: 1.0rn"; $headers.= "Content-type: text/html; charset=iso-8859-1rn"; $message=" <img> <b>You are one step away to cast your vote.<br> Click the link below to confirm your registration.<br><br> <a href='login.php'>Confirm !</a> </b>"; $mail_sent=mail( $to, $subject, $message, $headers ); echo $mail_sent ? "A confirmation mail has been sent to your e-mail address. Please click the link which is provided." : "We're sorry, sending confirmation mail failed. "; } else { $nickname= 'This login name already exists.'; exit; } else { echo "Please enter a valid e-mail."; echo "<style></style>"; echo "<img src='' class=''>"; echo "<form method='post' action='registration.php'> Nickname: <input type='text' value=isset($_POST['nickname']) name='nickname'> Password: <input type='password' name='password'> Confirm Password: <input type='password' name='cpass'> E-mail: <input type='text' name='email'> <input type='submit' value='Register'> </form>"; exit; } echo $nickname; echo "Please choose another nickname."; echo "<style></style>"; echo "<img src='' class=''>"; echo "<form method='post' action='registration.php'> Nickname: <input type='text'name='nickname'> Password: <input type='password' name='password'> Confirm Password: <input type='password' name='cpass'> E-mail: <input type='text' value=isset($_POST['email']) name='email'> <input type='submit' Register'> </form>"; exit; } else if (isset($_POST['password']) != isset($_POST['cpass'])) { echo "Passwords does not match."; echo "<style></style>"; echo "<img src='' class=''>"; echo "<form method='post' action='registration.php'> Nickname: <input type='text' value=isset($_POST['nickname']) name='nickname'> Password: <input type='password' name='password'> Confirm Password: <input type='password' name='cpass'> E-mail: <input type='text' name='email'> <input type='submit' Register'> </form>"; exit; } else {} } else if (!isset($_POST['nickname']) || !isset($_POST['password']) || !isset($_POST['cpass']) || !isset($_POST['email'])) { echo "Please fill in all fields."; echo "Please choose another nickname."; echo "<style></style>"; echo "<img src='' class=''>"; echo "<form method='post' action='registration.php'> Nickname: <input type='text' name='nickname'> Password: <input type='password' name='password'> Confirm Password: <input type='password' name='cpass'> E-mail: <input type='text' name='email'> <input type='submit' value='Register'> </form>"; exit; } else {} ?> what's wrong in the above code ? i am getting this error : Parse error: syntax error, unexpected '{' in C:\AppServ\www\Voting\registration.php on line 16 why ? Link to comment https://forums.phpfreaks.com/topic/59931-php-code-help/ Share on other sites More sharing options...
bluebyyou Posted July 14, 2007 Share Posted July 14, 2007 which one is line 16? edit: if (isset($_POST['nickname']) && isset($_POST['password']) && isset($_POST['cpass']) && isset($_POST['email'])) { missing a ending parenthesis. Link to comment https://forums.phpfreaks.com/topic/59931-php-code-help/#findComment-298037 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.