Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我填写登录表单,点击提交按钮,页面被重新加载,电子邮件id为空。如何填写电子邮件id文本?_Php - Fatal编程技术网

Php 我填写登录表单,点击提交按钮,页面被重新加载,电子邮件id为空。如何填写电子邮件id文本?

Php 我填写登录表单,点击提交按钮,页面被重新加载,电子邮件id为空。如何填写电子邮件id文本?,php,Php,我填写登录表单并单击提交按钮,页面被重新加载,电子邮件id为空。如何填写电子邮件id文本? 这是php代码 <?php if(isset($_POST["btnSubmit"])) { if($_POST["txtEmail"]=="") { $errormsg = "Please enter Email."; } else if($_POST["txtPassword"]=="") { $errormsg = "Please enter Password.";

我填写登录表单并单击提交按钮,页面被重新加载,电子邮件id为空。如何填写电子邮件id文本?
这是php代码

<?php 
if(isset($_POST["btnSubmit"]))
{   
if($_POST["txtEmail"]=="")
{
    $errormsg = "Please enter Email.";

}
else if($_POST["txtPassword"]=="")
{
    $errormsg = "Please enter Password.";
}

else
{

    $Email =  $_POST["txtEmail"];

    $Password =  md5($_POST["txtPassword"]);

    $info = mysql_query("select * from tbluser where Email ='$Email' and Password='$Password'");

    $count_info=mysql_num_rows($info);

    if($count_info>0)
    {
            while($a = mysql_fetch_array($info))
            {
                $b = strcmp($a["Email"],$Email);

                if($b==0 && $a["Password"]=="$Password" && $a["IsVisible"]==1)
                {   
                    $_SESSION["UserId"] = $a["user_id"];
                    $_SESSION["UserName"] = $a["user_name"];
                    header("Location:index.php");
                }
                else
                {
                    $errormsg="Register Your Account First.";
                }
            }
    }
    else
    {
        $errormsg="Invalid email or password.";
    }

}

}
?>

我想您正在寻找类似于:

<input type="text" id="txtEmail" name="txtEmail" placeholder="Email" value="<?php if(isset($Email)){echo $Email;} ?>" />
<!-- you might/want to escape $Email with something like htmlspecialchars -->
PHP部分

<?php
$Email=''; //added here so the email is not confined to the else block (better practice to initilize).<------
if(isset($_POST["txtEmail"])){$Email =  $_POST["txtEmail"];} // this will ensure that even if you have not typed in the password the email still shows up.
if(isset($_POST["btnSubmit"]))
{   
if($_POST["txtEmail"]=="")
//rest of your code

那你为什么不能填写呢?这个页面可能会帮你解决这个问题。如果我知道,那么我不会问它…现在我们可以解决它:)只有电子邮件是空白的?对不起,它无法工作。重新加载页面后仍然显示空白。你能详细阐述一下吗?你的英语不太好理解你想说的话。我读了你的英语,但我认为它有几个方面。抱歉,如果你同时填写电子邮件和密码(已测试),它也不起作用。现在检查,即使你没有键入任何密码,它也会显示警告:无法修改标题信息-标题已由发送(输出开始于C:\xampp\htdocs\meetitors\connection.php:5)在第42行(标题(“Location:index.php”);)的C:\xampp\htdocs\meetintors\login.php中,您是否收到任何警告?您正在从
connection.php的第5行发送一些输出,请检查该文件(即使
标记外的额外空间也算作输出)。
<?php
$Email=''; //added here so the email is not confined to the else block (better practice to initilize).<------
if(isset($_POST["txtEmail"])){$Email =  $_POST["txtEmail"];} // this will ensure that even if you have not typed in the password the email still shows up.
if(isset($_POST["btnSubmit"]))
{   
if($_POST["txtEmail"]=="")
//rest of your code
<input type="text" id="txtEmail" name="txtEmail" placeholder="Email" value="<?php echo htmlspecialchars($Email);?>" />
                                                                          // ^^ added here