未定义的索引:第10行的C:\ Apache24 \ htdocs \ checkup.php中的电子邮件

时间:2015-11-16 10:32:26

标签: php html

我是php的新手,我在我的网站上创建了一个登录系统,每件事情都运行正常,但每个页面的网站顶部都出现2个错误, 未定义的索引:第10行的C:\ Apache24 \ htdocs \ checkup.php中的电子邮件

我已经检查了我的mysql架构和编码但无法找到错误请建议我解决此错误。 enter image description here

这是checkup.php页面编码

<?php
include('dbconn.php');

if(!isset($_SESSION)) 
    { 
        session_start(); 
    } 


$user_check=  $_SESSION['email'];

$sql = mysqli_query($db,"SELECT fullname, email FROM register WHERE email='$user_check' ");

$row=mysqli_fetch_array($sql,MYSQLI_ASSOC);

$login_user = $row['email'];
$msguser = $row['fullname'];


?>

这是login.php&amp; loginconn.php页面

<html>
<head>
<title>online shopping</title>
<?php

 include 'header.php';

 include 'dbconn.php';
 include 'loginconn.php';



if ((isset($_SESSION['email']) != '')) 
{
header('Location: index.php');
}
?>
    <body>
<br>

<fieldset class="login_div">
 <legend>User Login</legend>


   <form method="POST" action="" >

  <table border="0"  cellspacing="10" >

  <tr>
<td><?php echo $error; ?></td>
</tr>
    <tr>
  <td width="279"><center>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;<label>Email:</label></td>
    <td width="385"><input type="text" id="email" name="email" placeholder="email"></td>
    </tr>
    <tr>
  <td><center>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;<label>Password:</label></td>
    <td><input type="password" name="password" placeholder="password"/></td>
    </tr>
    <tr>
    <td colspan="2"><input class="loginbtn" type="submit" name="submit" value="Login" /></td>
    </tr>
    </table>
    </form>
    </fieldset>
</body>
</html>
<?php

    include("dbconn.php"); 

    $error = ""; 
    if(isset($_POST["submit"]))
    {
        if(empty($_POST["email"]) || empty($_POST["password"]))
        {
            $error = "Both fields are required.";
        }else
        {

            $email=$_POST['email'];
            $password=$_POST['password'];


            $email = stripslashes($email);
            $password = stripslashes($password);
            $email =  mysqli_real_escape_string($db,$email);
            $password =  mysqli_real_escape_string($db,$password);
            $password = md5($password);


            $sql="SELECT id FROM register WHERE email='$_POST[$email]' and password='$_POST[$password]'";
            $result= mysqli_query($db,$sql);
            $row= mysqli_fetch_array($result, MYSQLI_ASSOC);


            if( mysqli_num_rows($result) == 1)
            {
                $_SESSION['email'] = $email;
                header("location: index.php"); 
            }
            else
            {
                $error = "Incorrect username or password.";
            }

        }
    }

?>

2 个答案:

答案 0 :(得分:0)

你错过了文件loginconn.php中的session_start()函数调用。添加与checkup.php相同的代码:

import struct
with open('tmp', "wb") as f:
  id1 = 1
  i = 0.5785536878880112
  fmt = "Hf"
  data = struct.pack('Hf', id1, i)
  f.write(data)
  print("no. of bytes:%d"%struct.calcsize(fmt))

答案 1 :(得分:0)

你如何调用checkup.php php页面?

在您的登录页面上添加操作:<form method="POST" action="checkup.php" >

在任何其他测试之前测试表单已提交:

if(isset($_POST["submit"])) { // other tests } 

更重要的是,您已忘记页面开头的session_start

session_start();

这将维护会话及其变量。