Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I send POST (Form) information without the user hitting Submit? 1

Status
Not open for further replies.

Tama

MIS
Jun 6, 2001
121
0
0
NZ
Hi there

How do I make a PHP script mimic a FORM sending POST information? I want to make a script that translates a search request and then sends it as $HTTP_POST_VAR to another script I have on my server.

Any ideas?

Cheers
Tama

I do my sums on fingers and thumbs.
 
If you must send the data by invoking the script through the web browser, see FAQ434-2502

However, doing it that way is the most resource-intensive way of doing it. Most of the time, making that particular script's functionality in multiple scripts is best done with PHP's include() function.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
If your question was about programmatically submitting an HTML form on a user's browser page, this is something PHP cannot do. PHP runs on the web server, not the web client.

To programmatically submit a form on a web page, you must use a client-side scripting language such as JavaScript. Getting details on how to do this in JavaScript is a question for the JavaScript forum.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
auto form submit (on change of a selection item)

<select name="cctype" onChange="document.thisForm.submit()" SIZE="1">
<option value="visa">Visa</option>

make sure you don't have a "submit" button on the page though, as it will over-ride the auto submit.
 
Hi guys

Thanks for the input - I should be a bit clearer about what I want to do. sleipnir had it right with his link to CURL. A simplified version of what I'm after follows:

Code:
[b]mypage.html[/b]
<form action='search-selector.php' method='POST'>
<input type='text' name='search_keywords'>
<select name='search_type'>
<option value='1'>Search Forums</option>
<option value='2'>Search Photos</option>
</select>
<input type='submit' value='Search'></form>

[b]search-selector.php[/b]
[i]Gets FORM information from [b]mypage.html[/b]
if (search-type=='1') then send FORM as POST to [b]search-forum.php[/b]
if (search-type=='2') then send FORM as POST to [b]search-photos.php[/b][/i]

[b]search-forum.php[/b]
[i]GNU script that parses HTTP_POST_VARS into search engine and displays results[/i]

The reason for "search-selector" existing is that the FORM information from mypage.html will need to be altered depending on whether forums/ photos etc. are getting searched.

I hope this makes sense - I think that CURL might be the way to go but I'll need some time to play with it.

Cheers
Tama

I do my sums on fingers and thumbs.
 
As I have said before, using cURL to pass data between scripts on the same physical server is the least-efficient way to do it. Using include() invoke the same core functionality from two different scripts is much better.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Ah... I think I just clicked...

I could put a case list in search-selector.php that does the required alterations to the POST info from mypage.html - and then include search-forum.php (or whatever) and the POST information would then be picked up from mypage.html (with alterations?)

Slap me if I've got it wrong again.

Tama

I do my sums on fingers and thumbs.
 
You're getting very close.

What you will have to do is take from search-forum.php the common functionality that both scripts need. Put that in a separate file. Then both scripts use include() to use functionality provided by the include-file.

You also have the benefit that you need only change the include-file to change the behavior of both search-selector.php and search-forum.php.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Hmmm... this might be a bit trickier than that...

search-forum.php is my "easy" name of the search function in phpBB which is sitting inside PHPNuke - so there's quite a few layers there.

It's 11:30am Monday morning here (New Zealand) so I'll have to wait until I get home before I can fiddle around with it.

Cheers
Tama

I do my sums on fingers and thumbs.
 
It's 18:40 Sunday, here. U.S. Central time zone.
<facetious>
It's like time travel!
</facetious>

PHPNuke is object-oriented. You can certainly instantiate its objects to perform the functions you need.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top