Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. login script returns blank page

login script returns blank page

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
phphtmltoolshelp
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    komanche
    wrote on last edited by
    #1

    I have written a login page but each time I login it returns a blank page even with a wrong password please help: the login page is as follows:

    <body>

    	<form action="methods/login.php" method="post">
    	
    
        	*   <label>Username:</label><input type="text" name="username" size="10" value="" />
            *   <label>Password:</label><input type="password" name="password" size="10" value="" />
            *   <input type="submit" name="login" value="Log In" />
            *   <input type="submit" name="join" value="Join" />
            
    
        </form>
    

    </body>
    </html>

    and the php login script is

    any help will be greatly appreciated

    G V M 3 Replies Last reply
    0
    • K komanche

      I have written a login page but each time I login it returns a blank page even with a wrong password please help: the login page is as follows:

      <body>

      	<form action="methods/login.php" method="post">
      	
      
          	*   <label>Username:</label><input type="text" name="username" size="10" value="" />
              *   <label>Password:</label><input type="password" name="password" size="10" value="" />
              *   <input type="submit" name="login" value="Log In" />
              *   <input type="submit" name="join" value="Join" />
              
      
          </form>
      

      </body>
      </html>

      and the php login script is

      any help will be greatly appreciated

      G Offline
      G Offline
      Gerben Jongerius
      wrote on last edited by
      #2

      I believe your MySql query may be failing, causing you to see nothing other then a blank page. Your code seems weird to me as you escape strings the same way as you do column names and table names, which is a nono for MySQL. If you want to escape table / column names use the query below instead.

      "SELECT `id` FROM `users` WHERE username= '$username' AND password='$pass'"

      K 1 Reply Last reply
      0
      • K komanche

        I have written a login page but each time I login it returns a blank page even with a wrong password please help: the login page is as follows:

        <body>

        	<form action="methods/login.php" method="post">
        	
        
            	*   <label>Username:</label><input type="text" name="username" size="10" value="" />
                *   <label>Password:</label><input type="password" name="password" size="10" value="" />
                *   <input type="submit" name="login" value="Log In" />
                *   <input type="submit" name="join" value="Join" />
                
        
            </form>
        

        </body>
        </html>

        and the php login script is

        any help will be greatly appreciated

        V Offline
        V Offline
        Vasudevan Deepak Kumar
        wrote on last edited by
        #3

        The default PHP.INI error notify settings are set to NOT DISPLAY. Check out DEVELOPER SETTINGS in error notify and enable it. By default the production setting is recommended. Also instead of tightly locking your application to MySQL, use Adodb Abstraction Library for PHP (http://adodb.sourceforge.net/[^])

        Vasudevan Deepak Kumar Personal Homepage
        Tech Gossips
        The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep!

        1 Reply Last reply
        0
        • G Gerben Jongerius

          I believe your MySql query may be failing, causing you to see nothing other then a blank page. Your code seems weird to me as you escape strings the same way as you do column names and table names, which is a nono for MySQL. If you want to escape table / column names use the query below instead.

          "SELECT `id` FROM `users` WHERE username= '$username' AND password='$pass'"

          K Offline
          K Offline
          komanche
          wrote on last edited by
          #4

          I have changed the query script and done a var_dump it returns the values entered but it still does not run the query script even with a wrong password.

          -

          No idea how because if you dont enter any fields it returns the error of supply username and password? any help anyone ??

          1 Reply Last reply
          0
          • K komanche

            I have written a login page but each time I login it returns a blank page even with a wrong password please help: the login page is as follows:

            <body>

            	<form action="methods/login.php" method="post">
            	
            
                	*   <label>Username:</label><input type="text" name="username" size="10" value="" />
                    *   <label>Password:</label><input type="password" name="password" size="10" value="" />
                    *   <input type="submit" name="login" value="Log In" />
                    *   <input type="submit" name="join" value="Join" />
                    
            
                </form>
            

            </body>
            </html>

            and the php login script is

            any help will be greatly appreciated

            M Offline
            M Offline
            Marc Firth
            wrote on last edited by
            #5

            That should work I think. - Removed quotes from 'id' - I added "LIMIT 1" to your query to only return a maximum of one result. You should also: - "Salt your passwords" - Clean Input using mysql_real_escape_string()

            Portfolio | Surrey Web Design, Web Hosting & IT Support

            K 1 Reply Last reply
            0
            • M Marc Firth

              That should work I think. - Removed quotes from 'id' - I added "LIMIT 1" to your query to only return a maximum of one result. You should also: - "Salt your passwords" - Clean Input using mysql_real_escape_string()

              Portfolio | Surrey Web Design, Web Hosting & IT Support

              K Offline
              K Offline
              komanche
              wrote on last edited by
              #6

              Thanks alot for all the input I have tried a couple of the solutions. I have had different outcomes with the same result. At the moment I am using Marc Firth's solution and getting "-Invalid username / password" with a wrong or correct password. With no values entered it returns "You must supply a username and password." Am not really good at reading and understanding the "IF" "ELSE" working but would appreciate if someone gives a clue to what to do.

              M 2 Replies Last reply
              0
              • K komanche

                Thanks alot for all the input I have tried a couple of the solutions. I have had different outcomes with the same result. At the moment I am using Marc Firth's solution and getting "-Invalid username / password" with a wrong or correct password. With no values entered it returns "You must supply a username and password." Am not really good at reading and understanding the "IF" "ELSE" working but would appreciate if someone gives a clue to what to do.

                M Offline
                M Offline
                Marc Firth
                wrote on last edited by
                #7

                Try to output the hashed (sha1) password, and compare it to the one in the database. i.e. for user "joe" with password "bloggs" run the following code and compare the output to the mysql query below First get the hash you are creating when you log in (notice the "die"):

                <?php
                /**
                ** handles the login feature of the site
                ** check username and password with variables in the database
                */
                require_once("../includes/ikobe.php");

                if (isset($_POST['username']) && isset($_POST['password'])) {
                $username = $_POST['username'];
                $password = $_POST['password'];

                $pass = sha1($password);
                die($pass);
                
                if (!empty($username) && !empty($password)) {
                    $query = "SELECT id FROM users WHERE username = '$username' AND password='$pass' LIMIT 1";
                    $query\_run = mysql\_query($query);
                    $query\_num\_row = mysql\_num\_rows($query\_run);
                
                    if (mysql\_num\_rows($query\_run) == 0) {
                        echo 'Invalid username / password combination';
                    } else {
                        echo 'Ok.';
                    }
                
                } else {
                    echo 'You must supply a username and password.';
                }
                

                }
                ?>

                Then compare it to the one in the database:

                The two results should match.

                Portfolio | Surrey Web Design, Web Hosting & IT Support

                1 Reply Last reply
                0
                • K komanche

                  Thanks alot for all the input I have tried a couple of the solutions. I have had different outcomes with the same result. At the moment I am using Marc Firth's solution and getting "-Invalid username / password" with a wrong or correct password. With no values entered it returns "You must supply a username and password." Am not really good at reading and understanding the "IF" "ELSE" working but would appreciate if someone gives a clue to what to do.

                  M Offline
                  M Offline
                  Marc Firth
                  wrote on last edited by
                  #8

                  This works (tested):

                  <?php
                  session_start();
                  mysql_connect('localhost', 'user', 'pass');
                  mysql_select_db('dbname');
                  if (isset($_POST['username']) && isset($_POST['password'])) {
                  $username = $_POST['username'];
                  $password = sha1($_POST['password']);

                  if (!empty($username) && !empty($password)) {
                  	$query\_run = mysql\_query("SELECT id, password FROM users WHERE username = '$username' AND password = '$password' LIMIT 1");
                  						
                  	if (mysql\_num\_rows($query\_run) == 0) {
                  		echo 'Invalid username / password combination';
                  	} else {
                  		echo 'Ok.';
                  	}
                  		
                  } else {
                  	echo 'You must supply a username and password.';
                  }
                  

                  }
                  ?>

                  Username:
                  " />

                  Password:
                  " />

                  Portfolio | Surrey Web Design, Web Hosting & IT Support

                  K 1 Reply Last reply
                  0
                  • M Marc Firth

                    This works (tested):

                    <?php
                    session_start();
                    mysql_connect('localhost', 'user', 'pass');
                    mysql_select_db('dbname');
                    if (isset($_POST['username']) && isset($_POST['password'])) {
                    $username = $_POST['username'];
                    $password = sha1($_POST['password']);

                    if (!empty($username) && !empty($password)) {
                    	$query\_run = mysql\_query("SELECT id, password FROM users WHERE username = '$username' AND password = '$password' LIMIT 1");
                    						
                    	if (mysql\_num\_rows($query\_run) == 0) {
                    		echo 'Invalid username / password combination';
                    	} else {
                    		echo 'Ok.';
                    	}
                    		
                    } else {
                    	echo 'You must supply a username and password.';
                    }
                    

                    }
                    ?>

                    Username:
                    " />

                    Password:
                    " />

                    Portfolio | Surrey Web Design, Web Hosting & IT Support

                    K Offline
                    K Offline
                    komanche
                    wrote on last edited by
                    #9

                    Thanks Marc and all the rest that worked and put in all the help. the code finally works and now I will have some fun adding levels to the login accounts.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups