Page 1 of 1
$POST variables
Posted: Tue Sep 27, 2005 4:11 am
by sebs
I have to redirect a page and I need the variables from that page.How can I include them in the redirect page.I read there is a posibility to use a session on the server.Either way could you help me?
Posted: Tue Sep 27, 2005 4:27 am
by shiznatix
sessions or use get like this
header("location: site.php?var=whatnot");
Posted: Tue Sep 27, 2005 4:36 am
by sebs
shiznatix wrote:sessions or use get like this
header("location: site.php?var=whatnot");
Could you be more specific?This is only working with GET?
could you explain to me how is this working.Sorry to bother you again.
Posted: Tue Sep 27, 2005 4:58 am
by shiznatix
Code: Select all
$var = $_POST['var'];
$other = $_POST['other'];
header("location: somepage.php?var=$var&other=$other");
that will send you to somepage.php and will send the variables $var and $other along with it. now those 2 variables will only be accessable by $_GET on the somepage.php, not by $_POST anymore. using a session you would do somting like
Code: Select all
session_start();
$_SESSION['var'] = $_POST['var'];
$_SESSION['other'] = $_POST['other'];
header("location: somepage.php");
then on somepage.php
Code: Select all
session_start();
echo $_SESSION['var'];//will echo what $_POST['var'] was originally
echo $_SESSION['other'];//will echo what $_POST['other'] was originally
understand?
Posted: Tue Sep 27, 2005 5:05 am
by sebs
Yes,thank you!
Posted: Tue Sep 27, 2005 7:16 am
by sebs
Sorry I asked stupid questions but based on your example I wrote:
<a href="<?php echo("moduli_contatto.php?name=$cname")?>"
and it's not working for the first two results,for the other 100 it works.All it's put in:
while($data=mysql_fetch_array($result)){
<table>
...
<a href="<?php echo("moduli_contatto.php?name=$cname")?>"
...
</table>
Is there a problem if the string are something like "A B C Plane"?
I think it has no sense
Posted: Tue Sep 27, 2005 7:33 am
by feyd
sebs wrote:Is there a problem if the string are something like "A B C Plane"?
I think it has no sense
yes, there can be a problem.
rawurlencode() can likely help you with it. Where does $cname come from?
$cname
Posted: Tue Sep 27, 2005 7:42 am
by sebs
$cname=$data[1];
company name from database nvarchar[255]
thanks
Posted: Tue Sep 27, 2005 9:12 am
by sebs
it works with rawurlencode(),thanks.It was really odd anyway.Why 100 work and the first one don't?
Posted: Tue Sep 27, 2005 9:48 am
by feyd
there are many characters that require escapement to work with URLs correctly..