Results 1 to 9 of 9

Thread: I NEED HELP MY LOGIN.PHP redirects to blank page logon.php

  1. #1
    Join Date
    Aug 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I NEED HELP MY LOGIN.PHP redirects to blank page logon.php

    logon.php
    PHP Code:
    <?php

    $host
    ="localhost"// Host name
    $username="****"// Mysql username
    $password="*****"// Mysql password
    $db_name="******"// Database name
    $tbl_name="login"// Table name

    // Connect to server and select databse.
    mysql_connect("$host""$username""$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");

    // username and password sent from form
    $tellerUserName=$_POST['tellerUserName'];
    $tellerPassword=$_POST['tellerPassword'];

    $sql="SELECT * FROM $tbl_name WHERE user_name='$tellerUserName' and user_password='$tellerPassword'";
    $result=mysql_query($sql);

    // Mysql_num_row is counting table row
    $count=mysql_num_rows($result);

    // If result matched $l_username and $l_password, table row must be 1 row

    if($count==1){

    // Register $l_username, $l_password and redirect to file "login_success.php"
    @session_register("tellerUserName");
    @
    session_register("tellerPassword");
    $_SESSION['tellerUserName'] = $_POST['tellerUserName']; // store username
    header("location:index.php");

    }
    else {
    header("location:login.php?loginFailed=true&reason=password");
    }

    ?>
    Login.php

    PHP Code:
    <script type="text/javascript">
                    function 
    validateForms()
                    {
                    var 
    a=document.getElementById('tellerUserName').value;
                    var 
    b=document.getElementById('tellerPassword').value;
                    if (
    a==null || a=="")
                      {
                      
    alert("Username must be filled out");
                      
    document.getElementById('tellerUserName').focus();
                      return 
    false;
                      }
                    if (
    b==null || b=="")
                      {
                      
    alert("Password must be filled out");
                      
    document.getElementById('tellerPassword').focus();
                      return 
    false;
                      }
                    }
    </script>
        </head>    
    <body>
            <form name="login" method="post" action="logon.php" onSubmit="return validateForms()" id="login" >
     <div id="preContainer">
                    <div class="header">
                            <div class="logo"></div>
                            <div class="grayBar2 clear"> </div>
                    </div> 

  2. #2
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    Welcome to the forums!
    Are there any errors when you run your code? Or is the page just blank.

    From skimming over your code I can't see anything, but there are a couple of issues.
    1. You are not escaping the values from your form! This means people could mysql inject into your database
    2. Mysql is being depricated. You should use mysqli instead.

  3. #3
    Join Date
    Aug 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i am new to php, am using php 5.4.32, the first code it brought was to change session_register, ichanged it to @session_register, now it brings out no error code, just a blank page, and the sql version is 5.5.37-cll,

  4. #4
    Join Date
    Aug 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    do u mean i should change mysql in the script to mysqli. eg mysql_connect("$host", "$username", "$password")or die("cannot connect");
    will now be mysqli_connect("$host", "$username", "$password")or die("cannot connect");

  5. #5
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    Error codes are very useful while debugging code. Remove the @ symbol and then check the error.
    You shouldn't actually need either of the @session_register lines. Try deleting them.

    You need to escape your values before running them in a mysql query. Look at mysql_real_escape_string

  6. #6
    Join Date
    Aug 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i removed the 2 session_register and changed all mysql to mysqli and i got this [01-Sep-2014 04:35:47 UTC] PHP Fatal error: Call to undefined function mysqli_query() in /home/nwsob/public_html/2/1/sgpbo/admin-teller/logon.php on line 18

    *I have used this script with another host and it function properly*

  7. #7
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    Chances are then that your host doesn't have mysqli installed. You'll need to use mysql instead then.

  8. #8
    Join Date
    Sep 2014
    Posts
    5
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    php 5.4 does NOT include the use of mysql OR mysqli you MUST use PDO or downgrade your PHP version to 5.3 there is NOT other option.

  9. #9
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Quote Originally Posted by Bionic View Post
    php 5.4 does NOT include the use of mysql OR mysqli you MUST use PDO or downgrade your PHP version to 5.3 there is NOT other option.
    I'm not sure where you got that idea.

    MySQL functions were deprecated in php 5.5.x ref. This does not mean it was removed, only that it is strongly discouraged and that you should use MySQLi or PDO instead. MySQL is probably going to be removed in version 6.0 which has been in development for many years now and as far as I can see there is still no release date for it. The 5.x series came out in 2004.

    See this post for more information.
    Last edited by james438; 09-04-2014 at 03:23 AM.
    To choose the lesser of two evils is still to choose evil. My personal site

Similar Threads

  1. Login form that redirects to the page it came from
    By Beverleyh in forum Looking for such a script or service
    Replies: 3
    Last Post: 06-18-2009, 04:59 AM
  2. Blank page because of an echo
    By naiani in forum PHP
    Replies: 10
    Last Post: 09-01-2007, 07:56 PM
  3. Blank Page on internet
    By rob11 in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 05-11-2007, 04:03 PM
  4. Replies: 0
    Last Post: 02-28-2007, 01:38 AM
  5. (Auto Yahoo Login) Getting Logon Status
    By trippin in forum JavaScript
    Replies: 5
    Last Post: 01-16-2007, 06:37 AM

Bookmarks

Posting Permissions

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