Site Cloner PHP Script
Bargain Hunter PHP Script
Job Hunter PHP Script
Site Login and Access Control PHP Script

Retrieving Post Variables from a Joomla Form

To retrieve the values from a Joomla component you can use JRequest::getVar() to grab the variable and use a cookie to set the variable’s value. Cookies can be made in all content management systems like Joomla, Worpdress and Drupal for which they can be retrieved elsewhere. Importing sessions is another story.

Below is an example to retrieve form variables like first name, last name and email address and then make cookies for all values. 

$firstname=JRequest::getVar( ‘firstnm’,’firstnom’,’default’,’string’ );
$lastname=JRequest::getVar(‘lastname’, ‘default’, ‘post’, ‘string’);
$email_address=JRequest::getVar(’emailaddress’, ‘default’, ‘post’, ‘string’);
setcookie(“firstnm”, $firstname, time()+ 7200, “/”);
setcookie(“lastname”, $lastname, time()+ 7200, “/”);
setcookie(“email”, $email_address, time()+ 7200, “/”);

To use the variables in scripts outside of Joomla you only need to echo the value.

The code below is an example to autofill a form within another PHP script using a cookie made in Joomla. Importing a cookie uses the straight PHP code function setCookie() within Joomla.

<input type=”text” name=”lastname” value=”<?php echo $_COOKIE[‘lastname’]; ?>”/>