Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
question about $_POST method
Old 08-17-2008, 08:51 AM question about $_POST method
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
This is a bit of a longshot, and Im almost certain the answer is no! But anyway... Is there a way to send information via the POST method without using a form? For example, I have a form that is handled by just a PHP script on its own. The information is then checked and the user is then redirected back to the form page using a redirect header. The page then states whether or not it was all successful. The thing is, I would like to be able to send the form information back to the webpage so that the invalid fields can then be highlighted. Is there a way to do this in the way that I need? Or will I just have to set the form to submit to another form where the invalid fields are then highlighted? Does that make sense?
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
 
Register now for full access!
Old 08-17-2008, 09:35 AM Re: question about $_POST method
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
It can be done with JavaScript, as part of an AJAX request. Here is a thread I found about it: http://www.webmasterworld.com/forum91/4960.htm

Here is a simple way to do it with jQuery: http://docs.jquery.com/Ajax/jQuery.post

Unfortunately, JavaScript can be disabled. Since POST requests are made from the client, I'm not sure there is another way to do it.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 08-17-2008, 03:02 PM Re: question about $_POST method
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
To answer your main point, Php's cURL function http://uk2.php.net/curl will enable you to send POST data without a form.

The script below will send the variables $first_name and $last_name within the $_POST superglobal array just like a form would.

PHP Code:
<?php
 $ch 
curl_init('http://mysite.com/post_to_script.php');
 
curl_setopt ($chCURLOPT_POST1);
 
curl_setopt ($chCURLOPT_POSTFIELDS"first_name=Joe&last_name=Bloggs");
 
curl_exec ($ch);
 
curl_close ($ch);
?>
Although looking at your problem, your best bet would be to use a single script to handle the form and error handling. No redirect would be necessary and you wouldn't need to mess with cURL. Just have the form POST your data back to the script.

If your using PHP 5 you can use its exception model to handle errors in the submission http://uk2.php.net/exceptions.
maxxximus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to question about $_POST method
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12365 seconds with 12 queries