会话问题设置 [英] Session Issue Setting

查看:44
本文介绍了会话问题设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正处于PHP / Mysql的学习阶段因此我的问题:)


我有一个login.php页面传递以下值.. $ myusername

$ mypassword。在提交时,它将该数据发送到checklogin.php文件。


这是checklogin.php代码。

[php]<?php

include(" db.php");

$ myusername = $ _ POST [''myusername''];

$ mypassword = $ _ POST [''mypassword''];

$ que = mysql_query(" SELECT * FROM`instructors` WHERE`username` =''$ myusername''AND`password` =''$ mypassword''");

if(mysql_num_rows($ que)== 0)$ err ="" ;;

else

$ id = $ row [''id ''];

//保护MySQL注入(关于MySQL注入的更多细节)

$ myusername = stripslashes($ myusername);

$ mypassword = stripslashes($ mypassword);

$ myusername = mysql_real_escape_string($ myusername);

$ mypassword = mysql_real_escape_string($ mypassword);

$ sql =" SELECT * FROM instructors WHERE username =''$ myusername''和`password` =''$ mypassword''" ;;

$ result = mysql_query($ sql);

$ count = mysql_num_rows($ result);

if($ count == 1)

{

session_register(" myusername");

session_register(" mypassword");

session_register(" id");

header(" location:index.php");

}

else {

include(" ; navtop.php");

include(" nav.php");

echo"

< td width = 80 %valign = top>

< p class =''bodyHeading''>登录错误< / p>< / span>

< p>

< table border = 0 width = 600 class =''pbox11''>

< td>

< b>错误的用户名或密码 - 请等待< / b>< br>

< META HTTP-EQUIV =''刷新''CONTENT =''2; URL = index.php''>

< / td>< / table>

< br>< br>< br>< br>

< / span>< / td>< / table>< / span>< / td>< / table>" ;;

include(" navbot.php"); < br $>
}

?> [/ php]


我只是想把ID设置为标题以及用户名..这就是我迷路的地方。

af checklogin.php完成后移动到index.php页面。在那里我正在做一个mysql querty来找到用户我的ID号..但是ID没有传递到这个页面。


感谢您的帮助。


Nathan

I am in the learning phase of PHP/Mysql thus my question :)

I have a login.php page that passes the following values.. $myusername
$mypassword. on submit it sends that data to a checklogin.php file.

Here is that checklogin.php code.
[php]<?php
include("db.php");
$myusername=$_POST[''myusername''];
$mypassword=$_POST[''mypassword''];
$que = mysql_query("SELECT * FROM `instructors` WHERE `username`=''$myusername'' AND `password`=''$mypassword''");
if (mysql_num_rows($que)==0) $err = "";
else
$id = $row[''id''];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM instructors WHERE username=''$myusername'' and `password`=''$mypassword''";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1)
{
session_register("myusername");
session_register("mypassword");
session_register("id");
header("location: index.php");
}
else {
include("navtop.php");
include("nav.php");
echo "
<td width=80% valign=top>
<p class=''bodyHeading''>Login Error</p></span>
<p>
<table border=0 width=600 class=''pbox11''>
<td>
<b>Wrong Username or Password - Please wait</b><br>
<META HTTP-EQUIV=''Refresh'' CONTENT=''2;URL=index.php''>
</td></table>
<br><Br><br><Br>
</span></td></table></span></td></table>";
include("navbot.php");
}
?>[/php]

I am just trying to set the ID to the header as well as the username.. and that is where I get lost.
after the checklogin.php is done it moves to the index.php page. there i am doing a mysql querty to find the user my the ID number.. but the ID isnt getting passed to this page.

Thanks for any help.

Nathan

推荐答案

myusername
myusername


mypassword。在提交时,它将该数据发送到checklogin.php文件。


这是checklogin.php代码。

[php]<?php

include(" db.php");
mypassword. on submit it sends that data to a checklogin.php file.

Here is that checklogin.php code.
[php]<?php
include("db.php");


myusername =
myusername=


这篇关于会话问题设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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