I have got two page. page a.php <form action="b.php" method="post"> <input id="a1" type="text" value="keyword" name="a1" /> <input type="submit" value="post"/> </form> page b.php <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.
hello, I try to use below codes in page b, but after change the URL, it still lost the POST value. session_start(); if($_SERVER['REQUEST_METHOD']=="POST") { $_SESSION["a1"] = $_POST["a1"] ; } session_start(); if($_SERVER['REQUEST_METHOD']=="POST") { $_COOKIE["a1"] = $_POST["a1"] ; }
How are you attempting to retrieve the data you stored in the session? On the second page you would need to reference the $_SESSION array.
Hi! First Print Your $_POST["a1"] Value In b.php For Test And Then USE! <a href="b.php?id=<?php print $row["url"]; ?>" target="_self"><?php print $row["title"] . $_POST["a1"]; ?></a> If You Want To Print This Line In PHP Use This: print '<a href="b.php?id=' . $row["url"] . '" target="_self">' . $row["title"] . $_POST["a1"] . '</a>';
I thing you need this : put a form like this in the page b.php <form action="c.php" method="post"> <input id="a1" type="text" value="<?php echo $_POST['a1'];?>" name="a1" /> <input type="submit" value="post"/> </form> HTML:
Hello HungryMinds, I can Print and get my $_POST value in b.php witch is posted from a.php. not_dp_admin: why post the value to c.php? I don't quite understand.
I'd just do this: // page one session_start(); if($_POST) { $_SESSION['post'] = $_POST; } // page two session_start(); if(!$_POST) { $_POST = $_SESSION['post']; } PHP:
This Is The Sample CODE: Try It And Then Tell Us What U Wanna Do Next. CLICK HERE TO PREVIEW a.php <html> <body> <form action="b.php" method="post"> <input id="id" type="text" value="id" name="id" /> <input id="keyword" type="text" value="keyword" name="keyword" /> <input type="submit" value="post"/> </form> </body> </html> Code (markup): b.php <?php $row["url"] = "http://www.mysite.com/"; $row["title"] = "My Title"; $row["name"] = "My Name"; $keyword = $_POST["keyword"]; $id = $_POST["id"]; if($keyword == "" || $id == "") { echo "Blank Fields"; } else { print '<a href="b.php?id=' . $row["url"] . '" target="_self">' . $row["title"] . $_POST["keyword"] . '</a>'; print '<ul>'; print '<li>' . $row["name"] . $_POST["id"] .'</li>'; print '</ul>'; } ?> Code (markup):