从darabase导出信息

时间:2017-06-22 13:04:43

标签: php database

在你开始说我有一些不好的代码之前我知道。我只是一个尝试完成学业的初学者。 所以基本上我需要在登录时导出个人资料的多个数据,但这种方法似乎不起作用。还有其他选择吗? 我正在谈论这个:

     $_SESSION['s_id'] = $row['name'];
 $_SESSION['s_email'] = $row['email'];
 $_SESSION['s_phone'] = $row['phone'];



<?php
 include_once 'header.php';
?>

 
 <?php
  if (isset($_SESSION['s_id'])){
   echo '<form action="logout.php" method="POST">
  <button type="submit" name="submit">Logout</button>
 </form>';
  } else {
   header("Location: login.php?login=failed");
   exit();
  }
 ?>
 
<div class="container">
      <div class="row">
      <div class="col-md-5  toppad  pull-right col-md-offset-3 ">
           <A href="edit.html" >Edit Profile</A>

        <A href="edit.html" >Logout</A>
       <br>
<p class=" text-info">May 05,2014,03:00 pm </p>
      </div>
        <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 col-xs-offset-0 col-sm-offset-0 col-md-offset-3 col-lg-offset-3 toppad" >
   
   
          <div class="panel panel-info">
            <div class="panel-heading">
              <h3 class="panel-title">Sveiks <?php echo $_SESSION['s_id'] ?></h3>
            </div>
&#13;
<?php

 session_start();

if ('POST' == $_SERVER['REQUEST_METHOD']) {

 include 'dbc.php';

 $login = mysqli_real_escape_string($conn, $_POST['login']);
 $pwd = mysqli_real_escape_string($conn, $_POST['pwd']);


 //error handler
 //check if inputs are empty
 if (empty($login) || empty($pwd)){
  header("Location: login.php?login=empty");
  exit();
 } else {
  $sql = "SELECT * FROM user WHERE name='$login'";
  $result = mysqli_query($conn, $sql);
  $resultCheck = mysqli_num_rows($result);
  if ($resultCheck < 1) {
   header("Location: login.php?login=error");
   exit();
  } else {
   if ($row = mysqli_fetch_assoc($result)) {
    //dehashing
    $hashedPwdCheck = password_verify($pwd, $row['pwd']);
    if ($hashedPwdCheck == false) {
     header("Location: login.php?login=error");
     exit();
    } elseif ($hashedPwdCheck == true) {
     //Log in user
     $_SESSION['s_id'] = $row['name'];
     $_SESSION['s_email'] = $row['email'];
     $_SESSION['s_phone'] = $row['phone'];
     header("Location: index.php?login=success");
     exit();
    }
   }
  }
 }
} else {
 header("Location: login.php?login=error");
 exit();
}
&#13;
&#13;
&#13;

0 个答案:

没有答案