Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-16-2012, 09:54 PM   PM User | #1
shile
New Coder

 
Join Date: Oct 2012
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
shile is an unknown quantity at this point
simulating a submit button

i want to make a script that will simulate submit button function if a certain condition is satisfied,i researched a bit and i found that i need to do it with php's curl functions...i sniffed what submit button does and what fields it produces,here is a picture of the sniffed submit button...can you help me make a curl script?

shile is offline   Reply With Quote
Old 10-16-2012, 11:24 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
All the submit button is, is an input with the name and value. You simply need to provide that name => value combination with a part of the form data in a curl.
Fou-Lu is offline   Reply With Quote
Old 10-17-2012, 11:57 AM   PM User | #3
shile
New Coder

 
Join Date: Oct 2012
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
shile is an unknown quantity at this point
but what about this last field,is it a cookie?
shile is offline   Reply With Quote
Old 10-17-2012, 01:21 PM   PM User | #4
Rowsdower!
Senior Coder

 
Rowsdower!'s Avatar
 
Join Date: Oct 2008
Location: Some say it's everything.
Posts: 2,007
Thanks: 5
Thanked 395 Times in 388 Posts
Rowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura about
I'm not familiar with the Joomla JXTC appointment book system but the last one looks like it's just a token (probably session-specific) that the page generates in order to validate the user to prevent people sending submit data to them "in the blind." You will probably have to visit their page once to get the token, and then again to submit the data.

Whether that particular variable comes from a cookie or not, I can't say (I have no idea how you generated your table of data) but your cURL can be set to use cookies if needed so you will eventually be good to go either way. You'll just have to feel it out.
__________________
The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
See Mediocrity in its Infancy
It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
Seek and you shall find... basically:
validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

Last edited by Rowsdower!; 10-17-2012 at 01:23 PM..
Rowsdower! is offline   Reply With Quote
Old 10-17-2012, 02:24 PM   PM User | #5
shile
New Coder

 
Join Date: Oct 2012
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
shile is an unknown quantity at this point
i generated this table from fiddler,i sniffed what submit button did so i can make my curl script...this is my script that doesnt work...

PHP Code:
$curl_connection =curl_init('here is the site where i want this script to process');
        
curl_setopt($curl_connectionCURLOPT_CONNECTTIMEOUT30);
        
curl_setopt($curl_connectionCURLOPT_USERAGENT,
        
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
        
curl_setopt($curl_connectionCURLOPT_RETURNTRANSFERtrue);
        
curl_setopt($curl_connectionCURLOPT_SSL_VERIFYPEERfalse);
        
curl_setopt($curl_connectionCURLOPT_FOLLOWLOCATION1);
      
        
        
$post_data['appointment']='10:00:00';
        
$post_data['title']='titl';
        
$post_data['email']='email';
        
$post_data['field1']='field1';
        
$post_data['field2']='field2';
        
$post_data['option']='com_jxtcappbook';
        
$post_data['view']='book';
        
$post_data['task']='save';
        
$post_data['id']='0';
        
$post_data['cid[]']='0';
        
$post_data['ordering']='0';
        
$post_data['parent_id']='1';
        
$post_data['published']='1';
        
        
$post_data['date']='2012-10-29';
        
$post_data['duration']='01:00:00';
        
$post_data['start']='10:00:00';
        
$post_data['end']='11:00:00';
        
$post_data['pop']='0';

=>
i have put put fields like this just for test<=
        
        foreach(
$post_data as $key =>$value){
        
$post_items[]=$key.'='.$value;
        }
        
$post_string=implode('&',$post_items);
        
        
curl_setopt($curl_connection,CURLOPT_POST,1);
        
curl_setopt($curl_connectionCURLOPT_POSTFIELDS$post_string);
        
$result curl_exec($curl_connection);
        
print_r(curl_getinfo($curl_connection));
        
curl_close($curl_connection); 
shile is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 07:12 AM.


Advertisement
Log in to turn off these ads.