0

hi people , i have writen this copde but when i run it it gives me thigs error

Parse error: syntax error, unexpected ';' in C:\xampp\htdocs\forum\signup.php on line 49

i have checked the line more than 10 times and i didnt found anything

<?php
include 'includes/connect.php';
include 'includes/header.php';
echo '<h3>Sign up</h3>';
if($_SERVER['REQUEST_METHOD']!='POST')
{
/*the form hasnt been posted yet display it 
not that the action="" will cause the form to post the same page it is on */
echo '<form method="post" action="">
Username: <input type="text" name="user_name" />
Password: <input type="password" name="user_pass" />
Password again:<input type="password" name="user_pass_check">
E-mail: <input type="email" name="user_email">
<input type="submit" value="Sign up" />
</form>';
}
else
{
$error = array();
if(isset($_POST['user_name']))
{
// the username exisits
if(!ctype_alnum($_POST['user_name']))
{
$errors[] = 'the username can only contain letters and digits.';
}
if(strlen($_POST['user_name'])>30)
{
$errors[] = 'the username field must not be empty.';
}
if(isset($_POST['user_pass']))
{
if($_POST['user_pass'] !=$_POST['user_pass_check'])
{
$errors[] = 'the passwords did not match. ';
}
if(!empty($errors))
{
echo 'Uh-oh.. a couple of fields are not filled in correctly..';
echo '<ul>';
foreach($errors as $key => $value)
{
echo '<li>'.$value.'</li>';
}
echo '</ul>';
}
else
{
$sql = "INSERT INTO users(user_name, user_pass, user_email, user_date, user_level) VALUES ('".mysql_real_escape_string($_POST['user_name'])."','".mysql_real_escape_string($_POST['user_pass']."','".mysql_real_escape_string($_POST['user_email'])."',NOW(),0)";
$result = mysql_query($sql);
if(!$result)
{
echo 'Something went wrong while registering , please try again later.'; 
}
else
{
echo 'Successfully registered. You can now <a href="singin.php">Sign in</a> }
}
}
include 'footer.php';
?>
2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by Awah Mohamed
0
<?php
include 'includes/connect.php';
include 'includes/header.php';

// Variable declaration
$username = mysql_escape_string($_POST["user_name"]);
$password = mysql_escape_string($_POST["user_pass"]);
$email = mysql_escape_string($_POST["user_email"]);
echo '<h3>Sign up</h3>';
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
    /*the form hasnt been posted yet display it
    not that the action="" will cause the form to post the same page it is on */
    echo '<form method="post" action="">
Username: <input type="text" name="user_name" />
Password: <input type="password" name="user_pass" />
Password again:<input type="password" name="user_pass_check">
E-mail: <input type="email" name="user_email">
<input type="submit" value="Sign up" />
</form>';
} else {
    $error = array();
    if (isset($_POST['user_name'])) {
        // the username exisits
        if (!ctype_alnum($_POST['user_name'])) {
            $errors[] = 'the username can only contain letters and digits.';
        }
        if (strlen($_POST['user_name']) > 30) {
            $errors[] = 'the username field must not be empty.';
        }
        if (isset($_POST['user_pass'])) {
            if ($_POST['user_pass'] != $_POST['user_pass_check']) {
                $errors[] = 'the passwords did not match. ';
            }
        }
        if (!empty($errors)) {
            echo 'Uh-oh.. a couple of fields are not filled in correctly..';
            echo '<ul>';
            foreach ($errors as $key => $value) {
                echo '<li>' . $value . '</li>';
            }
            echo '</ul>';
        } else {
            $sql = "INSERT INTO users(user_name, user_pass, user_email, user_date, user_level) VALUES (" .
                $username . "," . $password . "," . $email . ",CURDATE(),0)";
        }
        $result = mysql_query($sql);
        if (!$result) {
            echo 'Something went wrong while registering , please try again later.';
        } else {
            echo 'Successfully registered. You can now <a href="singin.php">Sign in</a>';
        }
    }
}
include 'footer.php';
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.