Reputation: 5801
how i can remember POST value when change the URL
Upvotes: 1
Views: 642
Reputation: 1752
What you're trying to achieve seem a little convulted to, and I think it would be wise to rethink your solution when you have more ideas about how you could solve what you're trying to do.
The way I understand your process flow you have this: (pseudocode)
a.php posts form with field text(id=a1) to b.php
b.php processes the form and creates a link to b.php?id=<url>
when link is clicked b.php is run again, but without form this time only get.
So b.php does two things:
It seems to me you're mixing the two and forgets that they are separate requests.
There are several ways you can achieve what you want of course. here is a list of a couple:
Hope this helps.
Upvotes: 0
Reputation: 683
you can use a hidden input to pass the value of a1
<input type="hidden" name="a1" value="$_POST['a1']" />
this will pass a1 to next page
Upvotes: 1
Reputation: 536587
Pass the value of $_POST["a1"]
in another parameter in the b.php?...
URL so that it can be accessible in b.php's $_GET
lookup later.
Maybe it's a cut-and-paste error, but this:
href="b.php?id=".$row["url"]."" target="_self"
doesn't make any sense, you seem to be trying to use double quotes inside a double-quoted string. Also, you're forgetting to HTML-encode your output, which results in XSS security holes, and you will also need to URL-encode content you're putting into a URL parameter.
<?php
$url= 'b.php?id='.urlencode($row['url']).'&a1='.urlencode($_POST['a1']);
?>
<a href="<?php echo htmlspecialchars($url); ?>">
<?php echo htmlspecialchars($row['title']); ?>
</a>
then
<li>
<?php echo htmlspecialchars($row['name']); ?>
(<?php echo htmlspecialchars($_GET['id']); ?>,
<?php echo htmlspecialchars($_GET['a1']); ?>)
</li>
(You can define a helper function with a shorter name like h()
to avoid having to type out echo htmlspecialchars()
so much.)
Upvotes: 3
Reputation: 398
If you want pass data you can put it in link as query string and get it again with GET or put it in SESSION or COOKIE
Upvotes: 1
Reputation: 157917
Just add this value to to the query string of the link.
and change POST method to GET
Upvotes: -1