Paul
Paul

Reputation: 197

Passing data between webpages

I have a webpage with a form on it. The heading of the form is this:

           <form name="sw" METHOD ="POST" ACTION="logger1.php">

After some event has happened, a javascript function submits the form like this:

           document.forms["sw"].submit();     

The php file logs the data from the form in a text file on the server, and then redirects the browser to another page. My issue is that I want to examine one of the values in the form from the previous page on the page that the browser is redirected to. I am completely lost. help!

Upvotes: 1

Views: 1114

Answers (6)

YonoRan
YonoRan

Reputation: 1728

Basically all the form information is being passed to the "logger1.php" file in the POST method. So you need to see what the code in the "logger1.php" file is and see exactly how the file is redirecting once it's done doing what it does. Then you can possibly append the variable you want passed on to the redirect method in the GET method.

Lets say the variable you want to pass on is:

$_POST['Some_variable']

and the redirect method is something like:

header('Location: some_file.php');

then you can append it this way:

header('Location: some_file.php?variable_name='.$_POST['Some_variable']);

Upvotes: 2

Laurence Burke
Laurence Burke

Reputation: 2358

Cant you put the variable that you want to look at as a get variable added to the url of the redirected page like so http://yourdomain/thepage.php?var=variable

Upvotes: 0

Chriszuma
Chriszuma

Reputation: 4557

You can append ?info=hello to the end of the URL it redirects to, then retrieve it in PHP with $_GET['info']

Upvotes: 1

monsieur_h
monsieur_h

Reputation: 1380

Have you considered using sessions? The $_SESSION[] array might keep your previously posted variable between pages.

Upvotes: 2

I think the best way to do this would be to store the value in a database. If you are using ASP.NET the easiest way to do this would be to set up a SQL Server Express database. They are free until you go over 10GB.

Upvotes: 0

Quentin
Quentin

Reputation: 943567

You can't. The information is not passed when the browser is redirected so there is no way to access it.

Upvotes: 0

Related Questions