Hello,
I have an interesting problem to solve ..
I am setting up a few radio buttons to establish a new or returning user. Using the below code I am getting the buttons to act the way I want them to, however, when no button is selected (I cannot have any "pre-selected" for this app) I get an "Undefined index: userType" error in addition to my own error message to the user. The "mUserTypes" array is what I am using to load the radio buttons, and my "selected" value is mNeworReturn[user_type].
Thanks for any help offered .. Frank
$this->mNeworReturn = array('user_type' => ' ');
$this->mUserTypes = array ('New' => 'I am a first time customer, 'Return' => 'I am a returning customer');
if (isset ($_POST['Login']))
{
$this->mNeworReturn['user_type'] = $_POST['userType'];
if (empty ($_POST['userType']))
{
$this->mUserTypeError = 1;
$this->_mErrors++
}
}
If needed to review this problem, the below is the whole constructor of the class .. Thanks
class CheckoutStep1
{
// Public stuff
public $mErrorMessage;
public $mLinkToLogin;
public $mLinkToRegisterCustomer;
public $mEmail = '';
public $mNeworReturn;
public $mUserTypes;
public $mUserTypeError;
public $mUserError;
private $_mErrors = 0;
// Class constructor
public function __construct()
{
if (USE_SSL == 'yes' && getenv('HTTPS') != 'on')
$this->mLinkToLogin =
Link::Build(str_replace(VIRTUAL_LOCATION, '', getenv('REQUEST_URI')),
'https');
else
$this->mLinkToLogin =
Link::Build(str_replace(VIRTUAL_LOCATION, '', getenv('REQUEST_URI')));
$this->mLinkToStep2 = Link::ToRegisterCustomer();
$this->mNeworReturn = array('user_type' => '');
$this->mUserTypes = array ('New' => 'I am a first time customer',
'Return' => 'I am a returning customer');
if (isset($_POST['Login']))
{
$this->mNeworReturn['user_type'] = $_POST['userType'];
if (empty ($_POST['userType']))
{
$this->mUserTypeError = 1;
$this->_mErrors++;
}
}
}