parse tokens in url for field values

dt dtcinc 23 Mar, 2009
I would like to populate field values based on tokens in the url, like
index.php?option=com_chronocontact&chronoformname=remove_request?Email=test@test.com=Dec07
I have searched, didn't find anything. I am converting a site to Joomla and need this functionality. I am a Joomla novice.

The old way was a forming a url like
http://site.com/remove.htm?Email=test@test.com=Dec07
and using JS in the form
		<script type="text/javascript"><!--
a=location.href;if(a.indexOf("=")>-1){a=a.split("=");
			document.forms[0].Email_address.value=a[1];
			document.forms[0].Newsletter.value=a[2];}
// -->
		</script>


How would I get this done in Joomla with CF? I am not restricting this to registered users, so pulling from a DB table won't work. Any help is appreciated.
Gr GreyHead 23 Mar, 2009
Hi dtcinc,

<?php
$email = getVar('Email');
?>
should give you a value from the url.

But your url needs to be correctly formed - one ? at the beginning of the query string then a series of &name1=value1&name2=value2 pairs.

Bob
dt dtcinc 23 Mar, 2009
Bob,

I am adding this to the top of the form code

<?php
$email = getVar('Email');
?>


and get an error

Call to undefined function getVar()



I am a novice, so please don't assume I know what I'm doing... thanks
nm nml375 23 Mar, 2009
I believe that should be something like this instead:
<?php
$email = JRequest::getVar('Email');
?>

Then, to prefill your form (if I understood your request correctly), you'd do something like this:
Enter email address: <input type="text" name="email" value="<?php echo($email); ?>" />
dt dtcinc 23 Mar, 2009
thanks, that code works great.
Gr GreyHead 23 Mar, 2009
Hi dtcinc,

Yes that's good, apologies for my mistake.

Bob
le leroy971 04 Apr, 2009
Merci beaucoup !
Fonctionne également pour passer des variables d'un formulaire à un autre.
A la place de :
<?php
$nom1=$_POST['nom1'];
$mail1=$_POST['mail1'];
?>
mettre :
<?php
$nom1 = JRequest::getVar('nom1');
$mail1 = JRequest::getVar('mail1');
?>
This topic is locked and no more replies can be posted.