PHP ver gevorderde |
|
Hey SiMa Leute,
Ik heb een registratie formuliertje gemaakt, waarbij je kan selecteren of je de 'newsletter' wilt ontvangen (Ja/Nee - waarde:
1/0) Ik heb gemaakt met sessions dat de ingevoerde gegevens
worden bewaard. Maar nu onthoud hij de 'yes / 1' wel, en de
'no / 0' niet. Iemand een idee hoe dit komt?
form: (templatePower)
{YES} <input name="newsletter" type="radio" value="1" {session_NEWSLETTER_YES} />
{NO} <input name="newsletter" type="radio" value="0" {session_NEWSLETTER_NO} />
{YES} <input name="newsletter" type="radio" value="1" {session_NEWSLETTER_YES} /> {NO} <input name="newsletter" type="radio" value="0" {session_NEWSLETTER_NO} />
sessions aanmaken:
<?PHP
if (empty ($_SESSION['log']['newsletter_yes'])){$_SESSION['log']['newsletter_yes'] = "checked"; }
if (empty ($_SESSION['log']['newsletter_no'])){ $_SESSION['log']['newsletter_no'] = "" ; }
?>
<?PHP if (empty ($_SESSION['log']['newsletter_yes'])){$_SESSION['log']['newsletter_yes'] = "checked"; } if (empty ($_SESSION['log']['newsletter_no'])){ $_SESSION['log']['newsletter_no'] = "" ; } ?>
Assignen aan TemplatePower:
<?PHP
$tpl -> assign (array (
"session_NEWSLETTER_YES" => $_SESSION['log']['newsletter_yes'],
"session_NEWSLETTER_NO" => $_SESSION['log']['newsletter_no'] ));
?>
<?PHP "session_NEWSLETTER_YES" => $_SESSION['log']['newsletter_yes'], "session_NEWSLETTER_NO" => $_SESSION['log']['newsletter_no'] )); ?>
nieuwe sessions aanmaken na submit:
<?PHP
if (isset ($_POST['add_profile']))
{
if ($_POST['newsletter'] == 1){ $_SESSION['log']['newsletter_yes'] = "checked"; }else{ $_SESSION['log']['newsletter_no'] = ""; }
if ($_POST['newsletter'] == 0){ $_SESSION['log']['newsletter_no'] = "checked"; }else{ $_SESSION['log']['newsletter_yes'] = ""; }
header ("LOCATION: register.php"); // Controleren of het werkt: NEE
}
?>
<?PHP if (isset ($_POST['add_profile'])) { if ($_POST['newsletter'] == 1){ $_SESSION['log']['newsletter_yes'] = "checked"; }else{ $_SESSION['log']['newsletter_no'] = ""; } if ($_POST['newsletter'] == 0){ $_SESSION['log']['newsletter_no'] = "checked"; }else{ $_SESSION['log']['newsletter_yes'] = ""; } header ("LOCATION: register.php"); // Controleren of het werkt: NEE } ?>
|