简单的php登录系统的问题 [英] problem with the simple php login system
问题描述
我在创建一个简单的登录系统时遇到了问题..
i我只是获取用户名和pwd表单数据库..如果用户名和密码正确...我只是想重定向到另一页显示
欢迎用户名
这是我的登录页面代码
i have a problem in creating a simple login system..
i am just fetching the username and pwd form database.. and if username and pwd is correct.. i am just trying to redirect to the other page to show that
welcome username
here is my login page code
<?php
$host = 'localhost';
$user = 'root';
$password = '';
$db = 'dbsneaker';
$link = mysql_connect($host,$user,$password) or die('Error in Server information');
mysql_select_db($db,$link) or die('Can not Select Databasse');
$userName = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$query = "select * from tbladmin where admin_usr_name='$userName' and admin_pwd='$password'";
$res = mysql_query($query);
$rows = mysql_num_rows($res);
if($rows==1)
{
//echo "login successful";
$_SESSION['userName']=$userName; // please take a look on session vairiable please
$_SESSION['password']=$password;
header("location:success.php");
}
else
{
echo 'wrong Username or password';
}
?>
这里是success.php页面的代码
here is the code for success.php page
<?php
session_start();
if($_SESSION['userName']!='')
{
header("location:login_form.php");
}
else
{
echo '<h2>Successfully Login <br /> </h2>';
echo "hello=". $_SESSION['userName'];
echo '<a href="logout.php"> Log Out</a>';
}
?>
i我遇到这些错误
(!)注意:未定义的索引:C中的用户名:\ wamp \ www。\ tlogin sys \ .success.php在第3行
通话栈
#时间记忆功能位置
1 0.0006 671144 {main}().. \ .success.php: 0
成功登录
(!)注意:未定义的索引:C中的用户名:\ wamp \\\login sys \\ 11号线上的@success.php
通话栈
#时间记忆功能位置
1 0.0006 671144 {main}().. \ success.php:0
i am getting these errors
( ! ) Notice: Undefined index: userName in C:\wamp\www\login sys\success.php on line 3
Call Stack
# Time Memory Function Location
1 0.0006 671144 {main}( ) ..\success.php:0
Successfully Login
( ! ) Notice: Undefined index: userName in C:\wamp\www\login sys\success.php on line 11
Call Stack
# Time Memory Function Location
1 0.0006 671144 {main}( ) ..\success.php:0
推荐答案
host = ' 本地主机'跨度>;
host = 'localhost';
user = ' 根跨度>;
user = 'root';
密码 = ' '跨度>;
password = '';
这篇关于简单的php登录系统的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!