Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

oh oh no: single login sign-in

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

oh oh no: single login sign-in

Postby sarjanajava » Thu Jan 30, 2003 10:07 am

i have database for login to store username and password
how do ....to create a single login?

here is my coding FORM
[code]

<!doctype html public "-//W3C//DTD HTML 4.0 //EN">


<html>
<head>
<title>Login Page!</title>
</head>
<body bgcolor=#FFGHFF">
<center><?php echo $errmsg;

?></center>
<form method="post" action="loginsession1.php">
<table width="50%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>username</td>
<td>
<input type="text" name="username">
</td>
</tr>
<td>Password</td>
<td>
<input type="password" name="password">
</td>
</tr>
<tr>
<td>&</td>
<td>
<input type="submit" name="submit" value="submit">
</td>
</tr>
</table>
</form>
</body>
</html>
User avatar
sarjanajava
New php-forum User
New php-forum User
 
Posts: 41
Joined: Wed Nov 27, 2002 10:59 pm

Postby Joan Garnet » Sat Feb 01, 2003 2:12 pm

loginsession1.php
Code: Select all
<?php
if(isset($HTTP_POST_VARS["username"])){
$server="localhost";
$login="mi_login";
$pass="***********";
$bbdd="database_name";
$table="mi_table";

$user = $HTTP_POST_VARS["user"];
$passwrd = $HTTP_POST_VARS["password"];

$db=mysql_connect($server,$login,$pass);     
mysql_select_db($bbdd,$db);
$sql = "SELECT user_id, username, user_password FROM ".$table." where username='$user' and user_password='$passwrd'";
$sql_result= mysql_query($sql,$db);
if ($row = mysql_fetch_array($sql_result)){
   do{
      echo "You are logged in ".$user."!!";
   }while   ($row = mysql_fetch_array($sql_result));
}else{
   echo "You are not logged in....";
}
mysql_close($db);
?>
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron