1

这是我的表单页面。按下登录时,它被重定向到 checkLogin 页面,但它是空的。没有回声工作。

<html>
    <title>User Login Form</title>
    <head></head>
    <body>

    <form name="form1" method="post" action="checkLogin.php">
    <td>
    <table width="100%" border="0" cellpadding="3" cellspacing="1" 
                bgcolor="#FFFFFF">        
    <tr>
    <td width="80">Username</td>
    <td width="6">:</td>
    <td width="300"><input name="myusername" type="text" id="myusername"></td>
    </tr>
    <tr>
    <td>Password</td>
    <td width="6">:</td>
    <td><input name="mypassword" type="text" id="mypassword"></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type="submit" name="Submit" value="Login"></td>
    </tr>
    </table>
    </td>
    </form>

    </td>
    </tr>
    </body>
</html>

这是 checkLogin 页面 这没有显示任何内容。我尝试了 mysql_error 但仍然没有显示。请帮忙

<?php
    include("config.php");
    echo "Check Login";
    $myusername=$_POST['myusername'];
    $mypassword=$_POST['mypassword'];        
    $myusername=stripslashes($myusername);
    $mypassword=stripslashes($mypassword);
    $myusername=mysql_real_escape_string($myusername);
    $mypassword=mysql_real_escape_string($mypassword);
    $sql="select j.jobid from jobs j,rcuser r where r.userName='$myusername'and r.password='$mypassword'";        
    echo "Hey".$myusername." ";
    $result=mysql_query($sql);
    while($col=mysql_fetch_array($result)){
            echo "<tr><th>Job Id</th>"</tr>;
            echo "<tr><td>" . $col['jobid'] . "</td><tr>";        
    }
    $count=mysql_num_rows($result);
    echo $count;
    if($count==1){
       session_register("myusername");
       session_register("mypassword");
       session_start();
       if(!session_is_registered($myusername){
            echo "Session expired";        
       }
       echo "is it???";        
    }
    else{
       echo "Invalid Username or Password";
    }
?>
4

2 回答 2

1

这是问题所在,请注意:Id</th>"</tr>;您没有以正确的方式构建 HTML 并回显。检查以下内容,您的错误在哪里。

echo "<tr><th>Job Id</th>"</tr>;
echo "<tr><td>" . $col['jobid'] . "</td><tr>";
于 2013-02-04T19:24:44.180 回答
0

请先检查此脚本,并告诉我结果,因为您构建编码的方式不够清晰。

`

$myusername=stripslashes(mysql_real_escape_string($_POST['myusername']));
$mypassword=stripslashes(mysql_real_escape_string($_POST['mypassword']));

$sql=" SELECT j.jobid 
            FROM jobs j,rcuser r 
            WHERE r.userName='$myusername' AND r.password='$mypassword' ";        

$result=mysql_query($sql) or die(mysql_error());

if(mysql_num_rows($result) === 1) {
echo "Username and Password is found";
}else {
echo "Error! No results found.";
}

?>`

于 2013-02-05T15:03:49.427 回答