Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2010
    Posts
    18
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Log in Page Help needed please

    Hi,
    I am a newbie trying to create a log in page and the page will not even display now.
    I have altered a few errors in my php log file and the last one says unexpected $end at line 101 ( which is the last line)

    My idea was to check that everything is ok and then run mysqli to check the database the value are in the database but the page is just blank.
    some guiding help would be great .
    PHP Code:
    <?php
    //start session
    session_start();
    include(
    'includes/conn.inc.php');
    include(
    'includes/db.inc.php');

    //form error alerts
    $error['alert'] = '';
    $error['user'] = '';
    $error['pass'] = '';
    $input['user'] = '';
    $input['pass'] = '';

    if(isset(
    $_POST['submit']))
        {
            if(
    $_POST['username'] == '' || $_POST['password'] == '')
                {
                    if(
    $_POST['username'] == '') {$error['user'] = 'required!';
                    if(
    $_POST['password'] == '') {$error['pass'] = 'required!';
                    
    $error['alert'] = 'Please fill in the required fields!';
                    
                    
    $input['user'] = $_POST['username'];    
                    
    $input['pass'] = $_POST['password'];
                    
                }
                else 
                    {
                        
    $input['user'] = htmlentities($_POST['username'], ENT_QUOTES);
                        
    $input['pass'] = htmlentities($_POST['password'], ENT_QUOTES);
                    
                        if (
    $stmt $mysqli->prepare("SELECT username, password FROM user WHERE username=? AND password = ? "))
                        
                            
    $stmt->bind_param('ss'$input['user'], md5($input['pass'].$config['secure']));
                            
    $stmt->execute();
                            
    $stmt->store_result();
                            
                            if (
    $stmt->num_rows 0)
                            {
                                
    $stmt->close();
                                
                                
    $_SESSION['username'] = $input['user'];
                                
                                
    header("Location: index.php");
                                                
                            }
    //                        else
    //                        {
    //                            $error['alert'] = "Username or Password incorrect !";    
    //                        }
                            
                        
    else 
                        {
                            echo 
    "ERROR could not do the MYSQLI ....";    
                        }
                    }
                
        }
        
    else {
        
    // show the form
    ?>
    <!DOCTYPE html>
    <html lang="en">
    <head> 
    <meta charset="UTF-8" />

    <title>Concept HQ Log in</title>

    <meta name="keywords" content="AddContentOf YourSite" />
    <link rel="stylesheet" href="css/style.css?v=1.0" />
    <!--[if lt IE 9]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    </head>

    <body>
        <section id="loginphp">
        <h1>Log In</h1>
        <div id="content">
            <form method="post" action="">
            <div>
                
                <label for="username">Username *</label>
                <input type="text" name="username" value="" />
                
                <label for="password">Password *</label>
                <input type="password" name="password" value="" />
                
                <p class="required">* required fields</p>
                
                <input type="submit" name="submit" value="Submit" class="submit"/>
            </div>
            </form>
        <?php 
            $mysqli
    ->close();
            } 
    //end else statement
            
         
    ?>
    </body>
    </html>

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,531
    Thanks
    8
    Thanked 1,091 Times in 1,082 Posts
    Put an opening { after the "if" statement on line 31 ...

    and put a closing } on line 50 (for that "if" statement).

  • #3
    New Coder
    Join Date
    Jan 2010
    Posts
    18
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hi,
    Thanks for the help I have tried and it still doesn't show up. I'm lost as what to do. i just want a login in script with prepare statements.
    Thank you for your help.

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,531
    Thanks
    8
    Thanked 1,091 Times in 1,082 Posts
    You get a blank white page because there is an error
    and your PHP error reporting is turned off. You need
    to enable it with your webhost config ... or you can
    try putting this line at the top ... see red ...

    <?php
    //start session
    session_start();
    error_reporting(E_ALL ^ E_NOTICE);
    include('includes/conn.inc.php');
    include('includes/db.inc.php');


    Let us know what the error says, and which line.


    .


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •