• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

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
0
Gerhard100198
Asked:
Gerhard100198
  • 4
  • 4
  • 2
1 Solution
 
freshmeatCommented:
can u post your code here?

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=...&variable2=...>NAME1<a>

hope it can help u
0
 
oubelkasCommented:
You can call a php page and along with it pass a name.

<a href="mypage.php3?name='carl'">

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
0
 
oubelkasCommented:
Sorry, freshmeat, didn't see your code yet....
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
oubelkasCommented:
Whoops

<? if ($name == "Carl") {

must be, in this case

<? if ($myname == "Carl") {

0
 
freshmeatCommented:
oubelkas, your comment is more detailed than mine
:)
0
 
Gerhard100198Author Commented:
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?
0
 
oubelkasCommented:
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
0
 
freshmeatCommented:
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!
:)
0
 
Gerhard100198Author Commented:
Freshmeat, submit yout original comment as an answer and the points are your.

Thanks.
0
 
freshmeatCommented:
if i understand u correctly, u mean u wanna use a method like ASP's "querystring", right?

u can try :
1,
<a href=b.php3?variable1=...&variable2=...>NAME1<a>

2,
<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 it can help u
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now