Hidden variable and session

I'm trying to get the value of a hidden input but when I try this echo $out_1; I see nothing.

I think that I have committed some basic error but I can't find it.

page n°1-.php

<form action="https://www.coinpayments.net/index.php" method="POST">
  <input type="hidden" name="item_number" value="article_1">
  <input type="hidden" name="currency" value="USD
  <input type="hidden" name="amountf" value="5.10000000">
  <input type="image" name="ordered" src="https://www.coinpayments.net/images/pub/CP-main-large.png"  alt="CoinPayments.net">
</form>

<?php

if(isset($_POST['ordered_x'], $_POST['ordered_y']))
{
    session_start();    
    $out_1=   $_POST['item_number'];
    $_session['item_number']= $_out_1;
}

page n°2--.php

<?php

session_start();
$ouput= $_session['item_number'];

echo "$ouput"; // it shows nothing when i try this

?>

When I try echo $out_1; in the first page to see what happens, it shows nothing again.

Upvotes: 3

Views: 385

Answers (1)

Rahul Koshti
Rahul Koshti

Reputation: 186

You haven't started session in second page. put session_start() function you also have to define html control for ordered_x and ordered_y in html form so php can post values for that control and after that your condition will become true.

<?php 
 if(isset($_POST['ordered_x'], $_POST['ordered_y']))
 {
   session_start();
   code.....
 }
?>

Upvotes: 2

Related Questions