<?php
include 'lib/db_conn.php';
$uid=$_REQUEST['uid'];
$pass=$_REQUEST['pass'];
if(($uid==NULL && $pass==NULL) ||($uid==NULL) ||($pass==NULL))
{
header("location:index.php?msg=Fields can't be left blank..");
}
$pass=md5($pass);
$sql1="SELECT * FROM `tb_user` WHERE `email`='$uid' AND `pass`='$pass'";
$rs1=mysql_query($sql1) or die (mysql_error());
$row1=mysql_fetch_array($rs1) or die (mysql_error());
$email=$row1['email'];
if($uid==$email)
{
session_start();
$_SESSION['id']=$row1['id'];
header("location:home.php");
}
else
{
header("location:index.php?msg=Wrong Credentials..");
}
?>
0
A
回答
0
最好不要寫在地址欄的消息,但只是標記化了,即:
header("location:index.php?msg=wcred");
,並在index.php:
if ($_GET['msg'] == "wcred") echo "Wrong Credentials..";
而且,正如愷提到, $uid=$_REQUEST['uid'];
必須
$uid=mysql_real_escape_string($_REQUEST['uid']);
而且,dnagirl提到,場空虛檢查是錯誤的。
而且,我說,exit
必須遵循的任何位置,頭
<?php
if((empty($_REQUEST['uid']) OR empty($_REQUEST['pass'])) {
header("location:index.php?msg=fempty");
exit;
}
include 'lib/db_conn.php';
$pass=md5($_REQUEST['pass']);
$pass=mysql_real_escape_string($pass);
$uid=mysql_real_escape_string($_REQUEST['uid']);
$sql1="SELECT * FROM `tb_user` WHERE `email`='$uid' AND `pass`='$pass'";
$rs1=mysql_query($sql1) or die (mysql_error());
$row1=mysql_fetch_array($rs1) or trigger_error(mysql_error());
if($row1) {
session_start();
$_SESSION['id']=$row1['id'];
header("location:home.php");
exit;
} else {
header("location:index.php?msg=wcred");
exit;
}
?>
0
您應該使用的代碼標籤。閱讀很難看。
我想你不應該鍵入「錯誤的憑據。」按原樣字母應該URL編碼。另外,您應該在發送header()-calls之後退出()執行。
順便說一句,你應該逃避$ uid或你可以得到與SQL注入的麻煩。
+0
好點 – 2010-04-22 13:22:27
相關問題
- 1. 在登錄錯誤,重定向到單獨的登錄頁面
- 2. LightOpenId不重定向到登錄頁面
- 3. 重定向HTTP到HTTPS,不重定向到登錄頁面
- 4. JAAS + Primefaces:登錄表單不會重定向到錯誤頁面
- 5. 登錄頁面重定向
- 6. 重定向到自動登錄的Liferay中的錯誤頁面
- 7. 重定向到IFrame的登錄頁面
- 8. 登錄重定向到錯誤的頁面
- 9. IIS重定向到錯誤的登錄頁面
- 10. 網站未重定向到指定頁面登錄
- 11. 重定向到https登錄頁面
- 12. 重定向到登錄頁面/彩盒
- 13. asp.net重定向到登錄頁面
- 14. 重定向到登錄頁面
- 15. 重定向到登錄頁面策略
- 16. 登錄頁面重定向不
- 17. 重定向到登錄頁
- 18. 自舉登錄按鈕不會重定向到登錄頁面
- 19. 成功登錄後不斷重定向到登錄頁面
- 20. FB.Connect.logoutAndRedirect不重定向到指定頁面
- 21. 不能重定向到一個PHP頁面登錄後
- 22. HttpServletResponse.sendError()不重定向到錯誤頁面
- 23. PHP頁面重定向錯誤信息只在頁面刷新後出現
- 24. WordPress的登錄頁面重定向到「找不到網頁」
- 25. 登錄頁面將不能重定向到安全頁面
- 26. PHP重定向到頁面,消息
- 27. angularJS重定向到登錄頁面而不是指定的網址
- 28. PHP不重定向到特定頁面
- 29. 重定向到登錄頁面,如果沒有登錄到facebook
- 30. 「未登錄」或頁面重定向的錯誤代碼
'如果(($ UID == NULL && $通過== NULL)||($ UID == NULL)||( $ pass == NULL))'...是過度的。該OR情況下是指與殼體是沒有必要的 – dnagirl 2010-04-22 13:25:33
'位置:'後緊跟由絕對URI,包括協議。對逃避http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html – TRiG 2010-04-22 13:39:24