未在确认页

时间:2015-07-11 21:53:55

标签: php

所以我在您注册后尝试在确认页面上显示用户名,密码和帐户类型。

以下是我的确认页面中的部分内容。我想如果我只是包含功能页面它会很好,因为它一旦你登录就适用于其他页面,但它没有显示我在帖子表格的末尾添加了$my_id = $_SESSION['user_id'];到注册页面,因为那是我做的对于登录页面,但它不起作用,它说“用户名”“密码”“帐户级别”未定义。

 <?php include('functions.php'); ?>
 <p>You have signed up for an account at ''.com. <br><br>
 Your username is: <b><?php echo $username ?></b> <br><br>
 Your password is: <b><?php echo $password ?></b> <br><br>
 Your Account level is: <?php echo $level_name ?></p> <br>

以下是我的功能页面,为活跃用户提供会话     

session_start();
function loggedin(){
if(isset($_SESSION['user_id']) && !empty($_SESSION['user_id'])){
    return true;
} else {
    return false;
}
}

if(loggedin()) {
$my_id = $_SESSION['user_id'];
$user_query = $mysqli->query("SELECT username, password, user_level, type FROM users WHERE id='$my_id'");
$run_user = mysqli_fetch_array($user_query);
$username = $run_user['username'];
$password = $run_user['password'];
$user_level = $run_user['user_level'];
$user_type = $run_user['type'];
$query_level = $mysqli->query("SELECT name FROM user_level WHERE id='$user_level'");
$run_level = mysqli_fetch_array($query_level);
$level_name = $run_level['name'];
}
?>

以下是设置会话的注册页面。

<form action = "register.php" method="POST">
<?php 

if(isset($_POST['submit'])){

if(empty($_POST['username']) 
|| empty($_POST['password'])
|| empty($_POST['email']) 
|| empty($_POST['Fname']) 
|| empty($_POST['Lname']) 
|| empty($_POST['Display1'])){

    echo '<p>Please make sure all fields are filled.</p>';

} else{

    $username = $_POST['username'];
    $password = $_POST['password'];
    $email = $_POST['email'];
    $Fname = $_POST['Fname'];
    $Lname = $_POST['Lname'];
    $Display1 = $_POST['Display1'];
    $Display2 = $_POST['Display2'];
    $userlevel = 2;
    $type = 'a';

    $query = $mysqli->query("INSERT INTO users (username, password, Fname, Lname, email, Display1, Display2, user_level, type)Values('{$username}', '{$password}', '{$Fname}', '{$Lname}', '{$email}', '{$Display1}', '{$Display2}', '{$userlevel}', '{$type}')");
    $subject = "Membership Confirmation";
    $message = "Hello, You have registered an account on  ";
    $from = "From: ";

    mail($email, $subject, $message, $from);

    $_SESSION['user_id'] = $user_id;
    header("location:signuppayment.php");

    }
}
      ?>

  <fieldset>
  <legend>Register</legend>
  <label>Username: <input class="text" type="text" name="username" id = "username" /></label>
 <label>Password: <input class="text" type="password" name="password" id = "password"/></label>
 <label>Email: <input class="text" type="text" name="email" id = "email" /></label>
 <label>First name: <input class="text" type="text" name="Fname" id = "Fname" /></label>
 <label>Last name: <input class="text" type="text" name="Lname" id = "Lname" /></label>
 <label>Display name 1: <input class="text" type="text" name="Display1" id = "Display1" /></label>
 <label>Display name 2: <input class="text" type="text" name="Display2" id = "Display2" /></label>

</fieldset>
<div class ="registerForm">
<input type="submit" name="submit" value="Register"/>
</form>

0 个答案:

没有答案