Same problem and here are the full details...
I'm running into the same problem and I know it's a matter of syntax so any help would be spectacular.
I'm passing a username variable from Joomla to log into a related site.
I've tried 2 different solutions and neither seems to work
The code that's giving me trouble is as follows:
Solution 1 (cURL seems to do absolutely nothing useful as it gives me connection results ad times and so forth but never actually redirects the page):
<?php
defined('_JEXEC') OR defined('_VALID_MOS') OR die( "Direct Access Is Not Allowed" );
$user = &JFactory::getUser();
$memid = $user->username;
//Prepare Data to post
$post_data['mem_id'] = $user->username ;
$post_data['pass'] = 'password' ;
$post_data['req'] = 'lgn';
$post_data['ent_fr'] = '1';
//Format info for posting
foreach ( $post_data as $key => $value) {
$post_items[] = $key . '=' . $value;
}
$post_string = implode ('&', $post_items);
//Initiate connection
$curl_connection = curl_init ('
https://secure.gggolf.ca/summerlea/index.htm');
// Set options
curl_setopt($curl_connection, CURLOPT_URL,'
https://secure.gggolf.ca/summerlea/index.htm');
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
$post_data['mem_id'] = $memid ;
$post_data['pass'] = 'password' ;
$post_data['req'] = 'lgn';
$post_data['ent_fr'] = '1';
// Replaced with test data $post_data['pass'] = $user->password ;
// Post data
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
// Perform Request
$result = curl_exec($curl_connection);
//show information regarding the request
print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection) . '-' . curl_error($curl_connection);
// Close connection
curl_close($curl_connection);
?>
Solution 2:
<?php
defined('_JEXEC') OR defined('_VALID_MOS') OR die( "Direct Access Is Not Allowed" ); <-- Required for Joomla
$user = &JFactory::getUser(); <-- Connect to Joomla user component
$memid = $user->username;
<script type="text/javascript" language="javascript">
var memnum
memnum = $memid ;
?>
</script>
<form method='post' action="
https://secure.gggolf.ca/summerlea/index.htm" name='logon'>
<input type='hidden' name='mem_id' value='<? php echo $memid;?>'>
// I also tried --> value= document.write(memnum) <-- To no avail
<input type='hidden' name='pass' value= 'password'>
<input type='hidden' name='req' value='lgn'>
<input type='hidden' name='ent_fr' value='1'>
<body onload="javascript:document.logon.submit();">