Results 1 to 5 of 5

Thread: Authentication

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2005
    Posts
    73

    Authentication

    I wrote this script today, and it works with check the password and everything, but how do i get it to go to another webpage when the password is right?
    Code:
    <form name="form1" method="post" action="<?php $_SERVER['PHP_SELF']; ?>?action=login">
    Username:<input type="text" name="u"><br>
    Password:<input type="text" name="p"><br>
    <input type="submit" name="Submit" value="Submit">
    </form>
    <?php
    $server = "localhost";
    $username = "root";
    $password = "";
    $datebase = "login";
    $a = 0;
    
    $db = mysql_connect($server, $username, $password);
    
    mysql_select_db($datebase, $db);
    
    $result = mysql_query("SELECT * FROM users WHERE username='$u'",$db) or die(mysql_error());
    
    
    
    while ( $r = mysql_fetch_array( $result ) ) {
    $uu = $r['username'];
    $pp = $r['password'];
    
    }
    
    if (isset($action) && $action == 'login') {
    
    if ($uu == $u && $pp == $p){
    	echo "Right!";
    	$a ++;
    }else
    	echo "Wrong!";
    	$a == 0;
    
    }
    print $a;
    ?>

    thanks for any help
    Last edited by JoshUK; Dec 8th, 2005 at 06:47 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width