ASPit - Totally ASP

Go Back PHPit Forums > General PHP > Advanced Topics
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
Thread Tools Search this Thread Display Modes
Old Yesterday, 09:30 PM #1
ronverdonk
Junior Member

Join Date: Jul 2006
Location: Netherlands
Posts: 11
Default

I don't like JavaScript very much so I would go for approach 2.
Approach 2 does not work because in this case you must enclose the array values within double quotes. This is your code as I tested it, together with a little program (B.PHP) that catches the POST en prints it out. Good luck!
PHP Code:
//createanewcurlresource
$ch=curl_init();

//setURLandotherappropriateoptions
curl_setopt($ch,CURLOPT_URL,"http://localhost/tst/b.php");

//setupthetestarray
$data=array();
$data['schoolName']='SCHOOLNAME';
$data['jobTitle']='JOBTITLE';
$data['shortIntro']='SHORTINTRO';
$data['body']='BODY';
$data['jobType']='JOBTYPE';
$data['jobGrade']='JOBGRADE';
$data['salary']='SALARY';
$proofRead="PROOFREAD";
$loginId='USERID';

//SetupthePOSTarray
$arrayToBePosted=array(
'schoolId'=>"{$data['schoolName']}",
'title'=>"{$data['jobTitle']}",
'shortDesc'=>"{$data['shortIntro']}",
'longDesc'=>"{$data['body']}",
'jobType'=>"{$data['jobType']}",
'jobGrade'=>"{$data['jobGrade']}",
'salary'=>"{$data['salary']}",
'proofRead'=>"{$proofRead}",
'userId'=>$loginId
);
//DoaPOST
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$arrayToBePosted);

//grabURL,andprint
curl_exec($ch);
?>
ProgramB.PHP
echo'

FormvariablesIreceived:

'
;
echo
'
';
print_r($_POST);
echo
'
';
?>

Ronald
ronverdonk is offline Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 02:44 PM.


Powered by vBulletin Version 3.6.0
Copyright 2000 - 2006, Jelsoft Enterprises Ltd.