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:
// create a new curl resource
$ch curl_init();

// set URL and other appropriate options
curl_setopt($chCURLOPT_URL"http://localhost/tst/b.php");

// setup the test array
$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';

// Setup the POST array
$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
               
);
// Do a POST
curl_setopt($chCURLOPT_POSTtrue);
curl_setopt($chCURLOPT_POSTFIELDS$arrayToBePosted);

// grab URL, and print
curl_exec($ch);
?>
Program B.PHP
echo '

Form variables I received: 

'
;
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.