Gerhard100198
asked on
How to POST variables between PHP scripts
Hi,
I would like to display a list of names in a script (A.PHP3). Whent the user clicks on any
of these names I would like to call script B.PHP3, passing it the name that was clicked as
a variable.
Is there a way of doing this without using a form?
I would like to list of name to appear as text (like links) instead of submit buttons.
Thanks.
Gerhard
I would like to display a list of names in a script (A.PHP3). Whent the user clicks on any
of these names I would like to call script B.PHP3, passing it the name that was clicked as
a variable.
Is there a way of doing this without using a form?
I would like to list of name to appear as text (like links) instead of submit buttons.
Thanks.
Gerhard
You can call a php page and along with it pass a name.
<a href="mypage.php3?name='ca rl'">
then with this value you can do the things you want in mypage.php3 like :
<input type="hidden" name="myname" value="<?echo $name; ?>">
<? if ($name == "Carl") {
echo "Yes, it is him!!";
} else {
echo "Mmmm, nope..it is Pete.";
};
?>
Joseph
<a href="mypage.php3?name='ca
then with this value you can do the things you want in mypage.php3 like :
<input type="hidden" name="myname" value="<?echo $name; ?>">
<? if ($name == "Carl") {
echo "Yes, it is him!!";
} else {
echo "Mmmm, nope..it is Pete.";
};
?>
Joseph
Sorry, freshmeat, didn't see your code yet....
Whoops
<? if ($name == "Carl") {
must be, in this case
<? if ($myname == "Carl") {
<? if ($name == "Carl") {
must be, in this case
<? if ($myname == "Carl") {
oubelkas, your comment is more detailed than mine
:)
:)
ASKER
Thanks guys, I've got it sorted out. Freshmeat, I think the points are yours, you were first with code that works.
Just out of interest though... Using the above method is like using a form with a GET. Is there a way to simulate a POST?
Just out of interest though... Using the above method is like using a form with a GET. Is there a way to simulate a POST?
No thanks Gerhard, you can accept freshmeat's comment as an answer. Don't forget the O'Reilly Q, ok?
Freshmeat,
Yep, mine was more detailed, but yours was right too according to Gerhard, so the points are yours ;)
Joseph
Freshmeat,
Yep, mine was more detailed, but yours was right too according to Gerhard, so the points are yours ;)
Joseph
sorry, i am not sure i can do it
maybe u can have a try about :
<script language=javascript>
function func1()
{
document.form1.submit()
}
</script>
<form name=form1 action="b.php3>
<input type=hidden name=variable1 value=...>
<input type=hidden name=variable2 value=...>
<a href="javascript:func1()"> NAME</a>
</form>
hope i can get the points successfully!
:)
maybe u can have a try about :
<script language=javascript>
function func1()
{
document.form1.submit()
}
</script>
<form name=form1 action="b.php3>
<input type=hidden name=variable1 value=...>
<input type=hidden name=variable2 value=...>
<a href="javascript:func1()">
</form>
hope i can get the points successfully!
:)
ASKER
Freshmeat, submit yout original comment as an answer and the points are your.
Thanks.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if i understand u correctly, u mean u wanna use a method like ASP's "querystring", right?
u can try : <a href=b.php3?variable1=...&
hope it can help u