简单的php登录系统的问题 [英] problem with the simple php login system

查看:113
本文介绍了简单的php登录系统的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在创建一个简单的登录系统时遇到了问题..

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆