 |
ช่วยดู code phpให้หน่อยคร้าบ งง คือว่าทำหน้า login แต่เวลาล๊อคอินเข้าไปแล้วทำไมยังอยู่หน้าเดิม งงมากว่า |
| |
 |
|
|
 |
 |
|
คือว่าทำหน้าlogin แต่เวลาล๊อคอินเข้าไปแล้วทำไมยังอยู่หน้าเดิม งงมากว่าๆๆๆๆ
-------admin_login.php ----------------- เวปล็อคอิน
<?php
include("Header.php");
session_start();
include("check/connect.php");
$msg = "";
if (isset($_POST['submit']))
{
$username = $_POST['username'];
$password = $_POST['password'];
$result = mysql_query("SELECT * FROM admin WHERE username='$username'",$link);
if(mysql_num_rows($result)>0)
{
$row = mysql_fetch_array($result, MYSQL_BOTH);
if($password == $row["password"])
{
$_SESSION['adminok'] = "ok";
$_SESSION['username'] = "username";
$_SESSION['password'] = "password";
header("Location:IndexAdmin.php");
}
else
{
$msg = "Password incorrect";
}
}
else
{
$msg = "Username incorrect";
}
}
?>
<form action="IndexAdmin1.php" method="post">
<div align="center">
<table width="684" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="775"><div align="center">
<p> </p>
<p> </p>
<table align="center">
<tr>
<td bgcolor="#FF9900" colspan="2" align="center"height="30"><font face="MS Sans Serif, Tahoma, sans-serif">
<b>Admin login</b></font> </td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><font face="MS Sans Serif, Tahoma, sans-serif"><b>UserName</b></font></td>
<td bgcolor="FFFFFF"><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><font face="MS Sans Serif, Tahoma, sans-serif"><b>Password</b></font></td>
<td bgcolor="#FFFFFF"><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td colspan="2" align="center"> <input name="submit" type="submit" value="submit"></tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</div></td>
</tr>
</table>
</form>
--------------Indexadmin.php-------------- หน้าเวปadminที่จะเข้า
<?php
include("HeaderAdmin.php");
include("check/connect.php");
include("check/common.php");
checklogin();
?>
--------------connect.php------------ ไฟล์ติดต่อฐานข้อมูล
<?php
$link = mysql_connect("localhost", "", "")
or die("Could not connect");
$db = mysql_select_db("sticker", $link)
or die("Could not select database");
?>
-------------common.php------------ เชค login
<?php
function checklogin()
{
session_start();
if(!isset($_SESSION['adminok']))
header("location: IndexAdmin1.php");
}
?>
Tag : - - - -
|
|
|
 |
 |
 |
 |
| Date :
6 พ.ค. 2548 13:54:00 |
By :
yuyu353 |
View :
2486 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
-------admin_login.php ----------------- เวปล็อคอิน
<?php
include("Header.php");
session_start();
include("check/connect.php");
$msg = "";
if (isset($_POST['submit']))
{
$username = $_POST['username'];
$password = $_POST['password'];
$result = mysql_query("SELECT * FROM admin WHERE username='$username' and password='$password'",$link);
if(mysql_num_rows($result)>0)
{
$_SESSION['adminok'] = "ok";
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
header("Location:IndexAdmin.php");
}
else
$msg = "Not member!";
exit;
}
?>
<form action="IndexAdmin1.php" method="post">
<div align="center">
<table width="684" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="775"><div align="center">
<p> </p>
<p> </p>
<table align="center">
<tr>
<td bgcolor="#FF9900" colspan="2" align="center"height="30"><font face="MS Sans Serif, Tahoma, sans-serif">
<b>Admin login</b></font> </td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><font face="MS Sans Serif, Tahoma, sans-serif"><b>UserName</b></font></td>
<td bgcolor="FFFFFF"><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><font face="MS Sans Serif, Tahoma, sans-serif"><b>Password</b></font></td>
<td bgcolor="#FFFFFF"><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td colspan="2" align="center"> <input name="submit" type="submit" value="submit"></tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</div></td>
</tr>
</table>
</form>
|
 |
 |
 |
 |
| Date :
6 พ.ค. 2548 16:16:31 |
By :
anata |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
-------admin_login.php ----------------- เวปล็อคอิน
<?php
ob_start(); /************* อยู่บรรทัดแรกตลอด *************/
session_start(); /************* อยู่บรรทัดแรกตลอด *************/
include("Header.php");
include("check/connect.php");
$msg = "";
if (isset($_POST['submit']))
{
$username = $_POST['username'];
$password = $_POST['password'];
$result = mysql_query("SELECT * FROM admin WHERE username='$username' and password='$password'",$link);
if(mysql_num_rows($result)>0)
{
$_SESSION['adminok'] = "ok";
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
header("Location:IndexAdmin.php");
}
else
$msg = "Not member!";
exit;
}
?>
<form action="IndexAdmin1.php" method="post">
<div align="center">
<table width="684" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="775"><div align="center">
<p> </p>
<p> </p>
<table align="center">
<tr>
<td bgcolor="#FF9900" colspan="2" align="center"height="30"><font face="MS Sans Serif, Tahoma, sans-serif">
<b>Admin login</b></font> </td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><font face="MS Sans Serif, Tahoma, sans-serif"><b>UserName</b></font></td>
<td bgcolor="FFFFFF"><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><font face="MS Sans Serif, Tahoma, sans-serif"><b>Password</b></font></td>
<td bgcolor="#FFFFFF"><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td colspan="2" align="center"> <input name="submit" type="submit" value="submit"></tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</div></td>
</tr>
</table>
</form>
|
 |
 |
 |
 |
| Date :
6 พ.ค. 2548 19:36:44 |
By :
*_* |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|