Hi guys, creating a log in script so my users can login to my website.

This is the code so far

<!DOCTYPE html> 
<html> 
<head> 
        <title>Richard Hemmings  </title>
        <meta name="viewpoint" content="width=device-width, intail-scale=1.0"> 
        <link href = "css/bootstrap.min.css"rel = "stylesheet"> 
        <link href = "css/stylesheet.css" rel = "stlesheet"> 

        </head>
        <body>

            <div class = "navbar navbar-inverse navbar-static-top">
                <div class = "container"> 
                 <div class = "navbar navbar-default navbar-fixed-bottom"> 

                <div class = "container"> 
                    <P class = "navbar-text">Site build and belongs to Richard Hemmings (C) 2015</P> 

                </div> 

        </div>
       <script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script><script src = "js/bootstrap/js" ></script>




</body>

</html>              

<?php
include('inc/header.php');
require('connection_db.php'); 

if (isset($_POST['submit'])){
    $uname = mysql_escape_string($_POST['uname']);
    $pass = mysql_escape_string ($_POST['pass']);
    $pass = md5 ($pass) ; 

    $uname = mysql_query("SELECT * FROM `users` WHERE `uname` = '$uname' AND `pass` = '$pass'"); 
if(mysql_num_rows($sql) > 0 {
    echo "you are now logged in successfully!"; 
    exit (); 

}else{ 
echo "Wrong Username and password entered please try again";
}

}else{


    echo $form = <<<EOT 
    <form action"login.php" method="POST">
    Username: <input type="text" name ="uname" /><br /> 
    password: <input type="password" name="pass" /><br />
    <input type="submit" name="submit" value="Log in" /> 
    </form> 

    EOT; 
} 




?>

This is the error message that I'm getting at the moment

Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\login.php on line 37

Any help would be brilliant sorry again for been a apain

Recommended Answers

All 3 Replies

Try that.

<?php
include('inc/header.php');
require('connection_db.php'); 

if (isset($_POST['submit'])){

    $uname = mysql_escape_string($_POST['uname']);
    $pass = mysql_escape_string ($_POST['pass']);
    $pass = md5 ($pass) ; 
    $uname = mysql_query("SELECT * FROM `users` WHERE `uname` = '$uname' AND `pass` = '$pass'"); 


    if(mysql_num_rows($sql)) > 0 {
        echo "you are now logged in successfully!"; 
        exit (); 
    }else{

    echo "Wrong Username and password entered please try again";

    }

}else{
    echo $form = <<<EOT 
    <form action"login.php" method="POST">
    Username: <input type="text" name ="uname" /><br /> 
    password: <input type="password" name="pass" /><br />
    <input type="submit" name="submit" value="Log in" /> 
    </form> 
    EOT; 
} 
?>

hey thanks for the replay I have tried what you said with the changes to the code you suggested

I'm now getting the following Parse error: syntax error, unexpected '>' in C:\xampp\htdocs\login.php on line 39

Here is the code

?php
include('inc/header.php');
require('connection_db.php'); 
if (isset($_POST['submit'])){
    $uname = mysql_escape_string($_POST['uname']);
    $pass = mysql_escape_string ($_POST['pass']);
    $pass = md5 ($pass) ; 
    $uname = mysql_query("SELECT * FROM `users` WHERE `uname` = '$uname' AND `pass` = '$pass'"); 
    if(mysql_num_rows($sql)) > 0 {
        echo "you are now logged in successfully!"; 
        exit (); 
    }else{
    echo "Wrong Username and password entered please try again";
    }
}else{
    echo $form = <<<EOT 
    <form action"login.php" method="POST">
    Username: <input type="text" name ="uname" /><br /> 
    password: <input type="password" name="pass" /><br />
    <input type="submit" name="submit" value="Log in" /> 
    </form> 
    EOT; 
} 
?>

Morning people I need to pick your brains I'm now getting the following erorr message:

Parse error: syntax error, unexpected end of file, expecting variable (T_VARIABLE) or heredoc end (T_END_HEREDOC) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN) in C:\xampp\htdocs\login.php on line 54

This is my code so far

<!DOCTYPE html> 
<html> 
<head> 
        <title>Richard Hemmings  </title>
        <meta name="viewpoint" content="width=device-width, intail-scale=1.0"> 
        <link href = "css/bootstrap.min.css"rel = "stylesheet"> 
        <link href = "css/stylesheet.css" rel = "stlesheet"> 

        </head>
        <body>

            <div class = "navbar navbar-inverse navbar-static-top">
                <div class = "container"> 
                 <div class = "navbar navbar-default navbar-fixed-bottom"> 

                <div class = "container"> 
                    <P class = "navbar-text">Site build and belongs to Richard Hemmings (C) 2015</P> 

                </div> 

        </div>
       <script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script><script src = "js/bootstrap/js" ></script>




</body>

</html>              

<?php
include('inc/header.php');
require('connection_db.php'); 
if (isset($_POST['submit'])){
    $uname = mysql_escape_string($_POST['uname']);
    $pass = mysql_escape_string ($_POST['pass']);
    $pass = md5 ($pass) ; 
    $uname = mysql_query("SELECT * FROM `users` WHERE `uname` = '$uname' AND `pass` = '$pass'"); 
   if(mysql_num_rows($sql) > 0 ) {  
        echo "you are now logged in successfully!"; 
        exit (); 
    }else{
    echo "Wrong Username and password entered please try again";
    }
}else{
    echo $form =<<<EOT
    //<form action"login.php" method="POST">
    Username: <input type="text" name ="uname" /><br /> 
    password: <input type="password" name="pass" /><br />
    <input type="submit" name="submit" value="Log in" /> 
    </form> 
EOT; 
}   
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.