dounao5856 2014-04-24 19:03
浏览 45
已采纳

为什么我的签名表格没有在php中正确提交

I am new to php so help will be appreciated. I am trying to submit this form for signing in.

<form method="post" action="sign_in_process.php">
<table>

<tr>
<td>
<label>E-mail: &nbsp;</label>
</td>
<td>
<input type="text" id="e_mail_address" name="email" />
</td>
</tr>
<tr>
<td id="e_passwd">
<label>Password: &nbsp;</label>
</td>
<td>
<input type="text" id="passwd" name="pass"/>
</td>
</tr>
</table>
<table>
<tr>
<td id="remember-me">
<input type="checkbox" value="remember" id="remember" />
Remember me &nbsp;
</td>
<td>
<button type="submit" id="sign_in_btn" name="sign_in_btn"></button>
</td>
</table>
</form>

This is my sign_in_process.php page

session_start();
if(isset($POST['sign_in_btn']))
{
$user_email=trim($POST['email']);
$user_password=hash("sha256",$POST['pass']);
check_email($user_email);
check_password($user_password);
if(isset($_SESSION['error']))
        {
        header("Location:sign-in.php");
            }
    else
    {
        $query="SELECT * from user WHERE user_email='$user_email' AND user_password='$user_password'";
        $retrieve=new retrieve();
        $hold=$retrieve-getdata($query);
        if($hold['user_active']==1)
        {
            $_SESSION['login']==true;
            $_SESSION['email']=$user_email;
            $_SESSION['pass']=$user_password;
            $_SESSION['username']=$hold['user_name'];
            $_SESSION['user_id']=$hold['user_id'];
            header("Location:index.php");

            }
            else if($hold['user_active']==0)
            {
                echo "you have to activate your account first by clicking the link we have sent you on your email";

                }
                else if(!$holder)
                {

                    echo "invalid user";
                    }
}
}

But when i try to sign in then nothing happens though i can see in the URL that form is submitted and it does go to sign_in_process.php but it doesn't perform anything it simply shows a blank page. In the code above check_email and check_password are simply the functions i m using for validation which i have in my functions.php file. I am requiring that function class with require_once.

  • 写回答

1条回答 默认 最新

  • dsiuy42084 2014-04-24 19:38
    关注

    I just added the underscore to the $_POST. Also you should never trust user input, so I added the mysql_real_escape_string(); :) And the «name»-attribute is missing at the "remember me" button

    if(isset($_POST['sign_in_btn']))
    {
    $user_email=trim($_POST['email']);
    $user_password=hash("sha256",$_POST['pass']);
    check_email($user_email);
    check_password($user_password);
    if(isset($_SESSION['error']))
            {
            header("Location:sign-in.php");
                }
        else
        {
            $user_email=mysql_real_escape_string($user_email);
            $user_password=mysql_real_escape_string($user_password);
            $query="SELECT * from user WHERE user_email='$user_email' AND user_password='$user_password'";
            $retrieve=new retrieve();
            $hold=$retrieve-getdata($query);
            if($hold['user_active']==1)
            {
                $_SESSION['login']==true;
                $_SESSION['email']=$user_email;
                $_SESSION['pass']=$user_password;
                $_SESSION['username']=$hold['user_name'];
                $_SESSION['user_id']=$hold['user_id'];
                header("Location:index.php");
    
                }
                else if($hold['user_active']==0)
                {
                    echo "you have to activate your account first by clicking the link we have sent you on your email";
    
                    }
                    else if(!$holder)
                    {
    
                        echo "invalid user";
                        }
    }
    }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么