Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

youlichika

macrumors member
Original poster
Aug 27, 2010
35
0
I have got two page.

page a.php
HTML:
<form action="b.php" method="post">
<input id="a1" type="text" value="keyword" name="a1" />
<input type="submit" value="post"/>
</form>

page b.php
HTML:
<a href="b.php?id=".$row["url"]."" target="_self" >".$row["title"]."'.$_POST["a1"].'</a>
<li>".$row["name"]."'.$_GET["id"].'</li>

$row["url"],$row["title"] and $row["name"] are all query from mysql.
After b.php received the $_POST value from a.php, it combined to a new hyperlink with $row["title"]. When click this hyperlink, the new value with ".$row["name"]." in <UL> <LI>.

Now when the url change to b.php?id=".$row["url"].", the $_POST value from a.php lost. How to deal with this problem? Thanks.
 
I try to use

Code:
session_start();
if($_SERVER['REQUEST_METHOD']=="POST") {
  $_COOKIE["key"] = $_POST["key"] ;
}
?>

or

session_start();
if($_SERVER['REQUEST_METHOD']=="POST") {
  $_SESSION["key"] = $_POST["key"] ;
}
?>
but it is failed.
 
Or you could pass the $_POST value along in the URL also.
PHP:
<a href="b.php?id=".$row["url"]."&a1=".$_POST["a1"]."\" target="_self" >".$row["title"]."'.$_POST["a1"].'</a>
<li>".$row["name"]."'.$_GET["id"].'</li>
Then "a1" will be available as $_GET['a1']
 
I try to use
Code:
session_start();
if($_SERVER['REQUEST_METHOD']=="POST") {
  $_COOKIE["key"] = $_POST["key"] ;
}
?>

or

session_start();
if($_SERVER['REQUEST_METHOD']=="POST") {
  $_SESSION["key"] = $_POST["key"] ;
}
?>
but it is failed.


Instead of testing the request method why not do this:
Code:
if(isset($_POST["key"])) {
    $_SESSION["key"] = $_POST["key"] ;
}
 
Great, thanks to all. Under your halp, I have solved the problem.
Shake hands ;)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.