Sending data from one page to another in php

  php

Basically I am getting input from python in my PHP script and I want to store that value in the session variable because I need that value on another page. I am getting value in PHP script and storing it in database but when I store that value in session variable I am getting null value don’t know why I tried all solutions available on internet but still unable to solve this problem.

PHP script:

if(isset($_POST['em'])) {
    $email = $_POST['em'];
    $password = $_POST['pas'];
    
    $checkUser1 = "SELECT * 
                    FROM users 
                    WHERE  email = '$email' AND  password = '$password'";
    $checkUserStatus1 = mysqli_query($conn,$checkUser1) 
                        or die(mysqli_error($conn));
    if(mysqli_num_rows($checkUserStatus1) > 0) {
        echo 'Sucessful';
    }else{
        echo 'nothing ';
    }
}else{
    echo 'nothing recevied';
}

This above code is basically getting values from python.

session_start();
$_SESSION['em'] = $email;

Here I am storing my data in session variable.

session_start();
if(isset($_SESSION['em'])) {
    $email = $_SESSION['em'];
    $checkUser1 = "SELECT name 
                    FROM users 
                    WHERE  email = '$email'";
    $checkUserStatus1 = mysqli_query($conn,$checkUser1) 
                            or die(mysqli_error($conn));
    $getMessageRow = mysqli_fetch_assoc($checkUserStatus1);
    echo $getMessageRow['email'];
}

Above is my next php page where i wanna use that session variable but I am getting null value. Kindly consider this question.

Source: Ask PHP

LEAVE A COMMENT