Page 1 of 1

post variable to another page without form

Posted: Fri Oct 18, 2013 6:18 am
by sectionLeader123
I have a form where the user submits data and when the form is submitted it runs the script info.php which is in the form action submits the data to the database. In the script I have used the last insert id function and set it to the variable $details. What I want to do is post the variable $details back to the form and echo it out on screen. When the user submits the form and info.php is executed it displays an alert box with the message Details Added and when the user clicks ok it displays another message saying "Do you want to close this tab?" and when the tab is closed I want the value for $details echoed on screen.

So far I have tried using sessions, so on the submission form I have:
session_start() at the top and to echo the variable I have:
<label>Job Reference Number:</label> <?php echo $_SESSION[$ref]; ?>

And in info.php I have session_start() at the top and to post the variable to the submission form I have:

$_SESSION[$details] = $ref;

Any suggestions would be greatly appreciated thanks

Re: post variable to another page without form

Posted: Fri Oct 18, 2013 11:07 pm
by Christopher
Please post your code.

Re: post variable to another page without form

Posted: Sat Oct 19, 2013 5:31 am
by priyankagound
Transferring variable VALUE can be accomplished with:
1) post form
2) in session
3) ajax call
you can do it with session by the following way:

session_start();
$_SESSION['user_profile'] = $user_profile['id'];

and use session variable every page you want the stored variables.
on every other pages you can retrieve the variable value like that

session_start();
$user_profile['id'] = $_SESSION['user_profile'];

Hope this helps.

Re: post variable to another page without form

Posted: Mon Oct 21, 2013 6:32 am
by sectionLeader123
Got it appreciate the help