更新:更改了一些sql查詢,現在它轉移到控制面板。儘管它顯示了這些錯誤。PHP登錄系統問題 - mysql_num_rows無效
警告:在session_start()[function.session啓動]:不能發送會話cookie - 頭已經發出(輸出開始/home/lewism/public_html/admin/rent/login_success.php:10)在/home/lewism/public_html/admin/rent/login_success.php 74行
警告:在session_start()[function.session啓動]:無法發送會話 緩存限制器 - 頭已經發送(輸出開始 /home/lewism/public_html/admin/rent/login_success.php:10) /home/lewism/public_html/admin/rent/login_success.php on line 74
警告:無法修改標頭信息 - (輸出開始於 /home/lewism/public_html/admin/rent/login_success.php:10)已在 /home/lewism/public_html/admin/rent/login_success中發送的標頭。上的PHP線76
〜嘿,夥計們,
只是利用phpeasysteps.com登錄腳本,它提供了以下錯誤,當我嘗試登錄,任何建議
警告:mysql_num_rows() :提供的參數不是/ home/lewism/public_html/ad中的有效MySQL結果資源第27行錯誤的用戶名或密碼
下面分/租/ checklogin.php對於checklogin.php
<?php
$host="localhost"; // Host name
$username="lewism_lewis"; // Mysql username
$password="teamgreen"; // Mysql password
$db_name="lewism_car"; // Database name
$tbl_name="Customers"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
?>
謝謝你們的代碼,
AIS
強制性 「逃避你輸入」。使用'mysql_real_escape_string'。 – Halcyon 2012-03-16 23:14:44