Welcome Guest, Not a member yet? Register   Sign In
Mysteriously empty $_POST
#1

Hy, I am trying to create page with many buttons. That when the button is pressed some text is send to the othe page. I can see that variable is storing data when I am showing the content in first page, but when I am movin to the other page is empty. 
PHP Code:
<?php
      
if(isset($_POST['button1'])) { echo "year=2021&category=mixhp"; }
if(isset(
$_POST['button2'])) { echo "year=2021&category=mixlp";}
 if(isset(
$_POST['button3'])) { echo "year=2021&category=cwhp";}
 if(isset(
$_POST['button4'])) { echo "year=2021&category=cwlp";}
 if(isset(
$_POST['button5'])) { echo "year=2021&category=ssbhp";}
 if(isset(
$_POST['button6'])) { echo "year=2021&category=ssblp";}
 if(isset(
$_POST['button7'])) { echo "year=2021&category=mixlp";}

$ananas $_REQUEST['button1'];
$ananas $_REQUEST['button2'];
$ananas $_REQUEST['button3'];
$ananas $_REQUEST['button4'];
$ananas $_REQUEST['button5'];
$ananas $_REQUEST['button6'];
$ananas $_REQUEST['button7'];
$ananas $_REQUEST['button8'];

$_POST['ananas']
    ?>
   
<form action="WEB PAGE ADRESS" method="post">
 <input type="submit" name="button1" value="CW/SSB - High Power"/>         
<input type="submit" name="button2" value="CW/SSB - Low Power"/>    
 <input type="submit" name="button3" value="CW - High Power"/>   
 <input type="submit" name="button4" value="CW - Low Power"/>
 <input type="submit" name="button5" value="SSB - High Power"/>
 <input type="submit" name="button6" value="SSB - High Power"/>   
 <input type="submit" name="button7" value="SSB - Low Power"/> 
 <input type="submit" name="button7" value="Check / Disqualified"/>
    <input type="submit" name="button8" value="National Competition"/>
 <input type="submit" name="button9" value="Honor - Roll List"/>   
 <input type="submit" name="button10"  value="Soapbox"/>
 <input type="submit" name="button11" value="Operator List"/>   
 <input type="submit" name="button12" value="Final Comments"/>
 </form>

Ob the other page I am using simple code to read the content: 
Reply
#2

PHP Code:
This is code from the other page:
<?
php
// nova koda
get_header();
if(isset(
$_POST['ananas'])){
$banana $_POST['ananas']; 
echo 
$_POST['ananas'];
echo 
$banana;

}

?>
Reply
#3

eee. Wrong code.

I have found solution:

PHP Code:
<div class="one"  text-aligncenter;>
<
form action="https://web.page/" method="post">
    <input type="hidden" name="button" value="year=2021&category=mixhp"/>     
    
<input type="submit" value="CW/SSB - High Power"/>    
</form>
<
form action="https://web.page/" method="post">        
    
<input type="hidden" name="button" value="year=2021&category=mixlp"/>
    <input type="submit" value="CW/SSB - Low Power"/>    
</form>
<
form action="https://web.page/" method="post">      
    
<input type="hidden" name="button" value="year=2021&category=cwhp"/>
 <
input type="submit" value="CW - High Power"/>   
</form
Reply
#4

HI, I think one way to accomplish this is by trying PHP sessions: for example:

//page1.php
<?php
if(isset($_POST['submit']))
{
session_start();
$_SESSION['name'] = $_POST['name'];
$_SESSION['email'] = $_POST['email'];
header('Location: page2.php');
}
?>
<html>
<head>
<title>Page1</title>
</head>

<body>
<form action="page1.php" method="POST">
<label>Name</label>
<input type="text" name="name"><br>
<label>Email</label>
<input type="text" name="email"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
--------------------------------------------------------------------------
//Page2.php
<?php
session_start();
$name = $_SESSION['name'];
$email = $_SESSION['email'];
?>

<html>
<head>
<title>Page2</title>
</head>
<body>
<b>Name:</b> <?= $name; ?><br>
<b>Email</b> <?= $email ?>
</body>
</html>
-------------------------------------------------------
Also CodeIgniter's Session Library makes things much easier, please go through their docs.
https://codeigniter.com/user_guide/libra...sions.html
for more general help please check this link too:
https://www.w3schools.com/PhP/php_sessions.asp
Hope this helps.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB