Jean Ouédraogo Jean Ouédraogo - 4 months ago 11
HTML Question

variables containing Post elements get empty after another post called

i have a problem keeping a post element in variables before calling one more time post in a second form .

briefly:
variable below contain elements from previous post

$img=isset($_POST['image'])?$_POST['image']:false;
$table=isset($_POST['tabl'])?$_POST['tabl']:false;


Then i have as next to the lines above the form below :

<form method="post" action="" style="padding-top:200px;padding-bottom:200px;padding-left:500px">

<div><span>Email</span></div> <input type="text" value="" name="user"/><br><br>
<div><span>Password</span></div> <input type="password" value="" name="pass"/><br><br>
<input type="submit" value="send" name="submit"/>
</form>


and right after pressing submit
$img
and
$table
are both empty .

how can i keep the values in
$img
and
$table
even after calling post again ?

any clue ?

Thanks

Answer

You aren't sending the variables you want in the POST data in your second form.

You could use a hidden field to send it,

A bit like this.

   <form method="post" action="" style="padding-top:200px;padding-bottom:200px;padding-left:500px">
    <input type="hidden" name="img" value="<?php echo $img;?>" />
    <input type="hidden" name="table" value="<?php echo $table;?>" />
    <div><span>Email</span></div>  <input type="text" value="" name="user"/><br><br>
    <div><span>Password</span></div>  <input type="password" value="" name="pass"/><br><br>
    <input type="submit" value="send" name="submit"/>
 </form>