Page 1 of 1

re-post variable on http-equiv=refresh ...

Posted: Thu Apr 26, 2012 1:30 pm
by inosent1
i run some form code which posts a variable to the next page

the next page is a form that does things and relies on the previously posted variable to tell it which record in the db to post to

once i submit to form, the table updates like it should and i redirect to the page where it all started.

but what i want is after i arrive at the second page, once i post, i want to stay on that page and hold onto the variable

eg page 1 Record List Page

Code: Select all

<form border=0 name="s_ud" action="assign.php" method="post">
<input type="hidden" value="<?php echo $row2[0] ?>" name="file_id" />
 
</form>

Page 2 Assign Task Page

Code: Select all

<form border=0 name="s_ud" action="assign_t.php" method="post">
<input type="hidden" value="<?php echo $row2[0] ?>" name="file_id" />
 
</form>

process request page

Code: Select all

<?
include 'dbinfo.inc.php';
//$term = $_POST['term'];
$term2 = $_POST['file_id'];

$query2 = "UPDATE ldata SET last_task='$task_r' WHERE file_id=$file_id";
mysql_query($query2);
?>
<html>
<head>
<meta HTTP-EQUIV="REFRESH" content="0; url=page1.php">



so instead of going back to page 1 i want to do this:

<meta HTTP-EQUIV="REFRESH" content="0; url=page2.php">

this will take me back to page 2, but the file_id # gets wiped out.

how can i redirect back to page 2 but keep the file_id?

Re: re-post variable on http-equiv=refresh ...

Posted: Thu Apr 26, 2012 1:35 pm
by x_mutatis_mutandis_x
inosent1 wrote:how can i redirect back to page 2 but keep the file_id?
You can store it in a session, and retrieve it in any of the pages

Re: re-post variable on http-equiv=refresh ...

Posted: Fri Apr 27, 2012 6:02 pm
by inosent1
not sure how to do that

in form A on page A on submit the variable in the form is

Code: Select all

<input type="text" name="fild_id">
on the next page, page B

Code: Select all

$file_id = mysql_real_escape_string($_POST['file_id']);

then on Page C i run a query to input into the DB WHERE file_id = '$file_id'

the data flows in like it is supposed to, and the page returns to the start, page A

however, the 'file_id' variable is lost.

what i want to do is return to Page B after Page C submits to the DB, but somehow i want to keep the file_id variable alive

Re: re-post variable on http-equiv=refresh ...

Posted: Mon Apr 30, 2012 11:07 am
by x_mutatis_mutandis_x
page B

Code: Select all

<?php
session_start(); //first line in your script

$_SESSION['file_id'] = mysql_real_escape_string($_POST['file_id']);
?>
pageC:

Code: Select all

<?php
session_start(); //first line in your script

$file_id = $_SESSION['file_id'];
//query to input into the DB where file_id = '$file_id'
?>