Forum Moderators: coopster

Message Too Old, No Replies

PHP script to grab URL query and enter it in form

PHP script to grab URL query and enter it in form

         

G_s_P

3:23 pm on Jul 6, 2006 (gmt 0)

10+ Year Member



Hi,

I've been working on this for ages and can't figure it out, my PHP isnt all that good so hopefuly someone here will find a few minutes to help me out.

OK, i want a customer to be able to enter a term in the URL - www.mywebsite.com/script.php?Term=WHATEVER

What i need to do is to have a script that will grab the term from the URL and then enter it in a form on a remote site which uses the POST method.

The Form name is 'MainSearch'
Action is 'search.asp'
Element Name is 'Search'
Value will be 'TERM'

The results can then be displayed in the remote website in the same window.

I've been told its easy but i've been at it for a very long time with not much luck.

Thank In Advance.

eelixduppy

11:28 pm on Jul 6, 2006 (gmt 0)



Welcome to WebmasterWorld G_s_P,

You can retrieve the term from the url query by using the $_GET [us3.php.net] superglobal. With this, you can then submit a form from your own site to the remote site. Something like this maybe?:


<form method="post" action="http://remote-host.com/search.asp">
Search<input type="text" name="Search" value="<?php echo $_GET['Term'];?>" size="40" /><br />
<input type="submit" value="Search!" /></form>

Good luck! I hope this helps.

G_s_P

8:51 am on Jul 7, 2006 (gmt 0)

10+ Year Member



Thanks... no idea how i was trying to do it but thats so simple (apart from the $_GET bit which i didnt know about).

Anyway, i changed it slightly so all fields are hidden and instead of having submit button i've used:

<body onLoad="document.MYFORMNAME.submit()">

So page automatically sends info to other website.

But mission complete. Thanks so much!

eelixduppy

9:08 am on Jul 7, 2006 (gmt 0)



Great! I'm glad you got it all sorted out ;)