I'm trying to sharpen my PHP skills, but am at a loss when it comes to arrays.
Here's the deal: I'm trying to set the value of a form element to be $emx - a variable that catches a parameter from a URL string i.e. [email protected]
Here is the array I have, which builds the form (this is PHP Yii)
'email' => array('type'=>'text', 'label'=>$this->t('Your email address'), 'value' => $emx, 'onFocus' => 'this.value=""'),
The HTML that it produces:
<input type="text" id="MDealSubscribeForm_email" name="MDealSubscribeForm[email]" onfocus="this.value=""" value="">
I have defined $emx as the following:
<?php
if ($_GET['emx'] != ""){
$emx = $_GET['emx'];}
else {
$emx = "Enter your email address";} ?>
The problem I'm having is that the value is not being set to $emx - regardless of it I append ?emx= to the URL or not, value is always ""
UPDATE: The php for if ($_Get['emx']... is in one file (a wrapper) and the 'email' => array(... is in a separate file - if that matters.
Do I have the array syntax wrong? I thought I'd simply need to put in $emx to set the value. Thanks for reading!
isset($_GET['emx']). Right before you make that array,var_dump($emx);to see what it is.