Re: Re: Session on PHP with MySQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear Bayu,

Sunday, January 12, 2003, 10:27:50 AM, you wrote:

BS> it seem to me you didn't use session at all,
BS> so where is the session problem?
yup now I use seesion,here my script [hope you ca help me]
<?
include "common.php";
include "setup.php";
global $user_name, $user_pass;
banner();

function auth($user_name, $user_pass) {
$sql = "select user_name from iduser where user_name='$user_name' and " ;
        $sql =  $sql .  " user_pass = '$user_pass' " ;

if (! $tampil = mysql_query($sql,$dbh))
   {
   echo mysql_error();
   return 0;
   }
$result  = mysql_query($sql);
if ( mysql_num_rows($result)==0)
{   echo  "<font face=verdana size=2>User ID atau Password yang anda masukkan tidak benar </font>"; }
else
    {
    echo "<center><font face=verdana size=2> Welcome <strong>$user_name</strong> </font></center><br>";
    }
}

function login_form() {
global $PHP_SELF;
?>
<html>
<head>
<title>Login Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body background="./image/bg.gif">
<form method="post" action="<?echo $PHP_SELF;?>">
  <table width="30%" align="center" border="0">
    <tr>
      <td height="40" colspan="2"><div align="center">
      <font size="4" face="Verdana"><strong>Login Required<br>
      </strong></font></div></td></tr>
    <tr>
      <td width="34%"><font size="2" face="Verdana">Nama</font></td>
      <td width="66%"><input name="user_name" type="text" id="user_name"></td>
    </tr>
    <tr>
      <td><font size="2" face="Verdana">Password</font></td>
      <td><input name="user_pass" type="password" id="user_pass"></td>
    </tr>
    <tr>
      <td colspan="2"><div align="center">
      <input type="submit" name="Submit" value="Login">
      <input type="reset" name="Reset" value="Clear">
      </div></td></tr>
  </table>
</form>
<center><font size=2 face="verdana">Have No LoginID please
<a HREF=./registrasi.php>Register</font></a></center><br>
</body>
</html>
<?
}

session_start();
if (!isset($user_name)) {
login_form();
exit;
}
else {
    session_register("user_name","user_pass");
    $name = auth($user_name,$user_pass);
    if (!$name) {
    echo "Wrong Authentication, pls relogin";
    exit;
    }

  else echo "welcome my $user_name";
}

footer();
?>


BS> it's very helping if you send us the error message,
for error mesage i just tell to user whit this script

    session_register("user_name","user_pass");
    $name = auth($user_name,$user_pass);
    if (!$name) {
    echo "Wrong Authentication, pls relogin";
    exit;
    }

BS> is it from the mysql,php,or something else?

I use php+mysql, thanks for yr support


-- 
Warm regards,
Afif
mailto:afif@sur.ogs-id.com



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux