Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.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
设置要在profile.php页面上使用的会话变量_Php_Mysqli_Session Variables - Fatal编程技术网

设置要在profile.php页面上使用的会话变量

设置要在profile.php页面上使用的会话变量,php,mysqli,session-variables,Php,Mysqli,Session Variables,当我通过localhost注册时,代码是有效的,但是当我上传站点时 它给了我很多错误,我修复了大部分错误,但有一个错误是会话变量 如果你想自己看,这是我的网站。。去填一下表格,你就会看到问题所在www.cancelliano.com 这是我的注册码 也请检查图片 <?php $mysqli = mysqli_connect("myhost","myuser name","my pass","my database name"); >// Check connection if

当我通过localhost注册时,代码是有效的,但是当我上传站点时 它给了我很多错误,我修复了大部分错误,但有一个错误是会话变量

如果你想自己看,这是我的网站。。去填一下表格,你就会看到问题所在www.cancelliano.com

这是我的注册码 也请检查图片

 <?php


$mysqli = mysqli_connect("myhost","myuser name","my pass","my database name");

>// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
error_reporting(E_ALL);
ini_set("display_errors", 1);
?>
// Set session variables to be used on profile.php page
<?php
$_SESSION['first_name'] = $_POST['first_name'];
$_SESSION['last_name'] = $_POST['last_name'];
$_SESSION['email'] = $_POST['email'];
$_SESSION['ty'] = $_POST['ty'];
$_SESSION['date'] = $_POST['date'];
$_SESSION['password'] = $_POST['password'];

>// Escape all $_POST variables to protect against SQL injections
$first_name = $mysqli->escape_string($_POST['first_name']);
$last_name = $mysqli->escape_string($_POST['last_name']);
$email = $mysqli->escape_string($_POST['email']);
$ty = $mysqli->escape_string($_POST['ty']);
$date = $mysqli->escape_string($_POST['date']);
$password = $mysqli->escape_string(password_hash($_POST['password'], PASSWORD_BCRYPT));
$hash = $mysqli->escape_string( md5( rand(0,1000) ) );

>// Check if user with that email already exists
$result = $mysqli->query("SELECT * FROM users WHERE email='$email'") or die($mysqli->error);

>// We know user email exists if the rows returned are more than 0
if ( $result->num_rows > 0 ) {

    $_SESSION['message'] = 'User with this email already exists!';
    header("location: error.php");

}
else { // Email doesn't already exist in a database, proceed...

    // active is 0 by DEFAULT (no need to include it here)
    $sql = "INSERT INTO users ( first_name, last_name, email,ty,date, password, hash) " 
            . "VALUES ('$first_name','$last_name','$email','$ty','$date','$password', '$hash')";

    // Add user to the database
    if ( $mysqli->query($sql) ){

        $_SESSION['active'] = 0; //0 until user activates their account with verify.php
        $_SESSION['logged_in'] = true; // So we know the user has logged in
        $_SESSION['message'] =



        header("location: profile.php"); 

    }

    else {
        $_SESSION['message'] = 'Registration failed!';

    }

}

//设置要在profile.php页面上使用的会话变量

尝试在所有内容的顶部包含以下代码,我看不到您的代码中有会话开始

session_start();

你的代码有很多语法错误。你能告诉我它们在哪里吗。。thanksI在索引页中启动了会话。。我不能在这里开始一个新的会话,它让我的会话已经开始了