...

View Full Version : with this the checkbox['emailme'] must have default UNCHECKED or does not matter ?



lse123
02-27-2008, 10:57 AM
In PHP code
if (isset($_POST['emailme'])) {

with this to work, in html the checkbox['emailme'] must have default UNCHECKED or does not matter ?

mlseim
02-27-2008, 02:46 PM
I believe that is correct. If a checkbox is "unchecked", it is actually null or not defined.

Ultragames
02-28-2008, 01:40 AM
That way is just fine, though you could also do something like

if ( array_key_exists('emailme', $_POST) ){

Just for informational purposes...

lse123
02-28-2008, 04:51 AM
what is the best [with unchecked checkbox] ?
--------------------------------------------
if (isset($_POST['emailme'])) {
mail($email,$subject,$message_customer,$headers);
$_SESSION['m'] = "An email message has been sent!" ;
} else {
$_SESSION['m'] = "No" ;
}
--------------------------------------------
$_SESSION['m'] = "No" ;
if (isset($_POST['emailme'])) {
mail($email,$subject,$message_customer,$headers);
$_SESSION['m'] = "An email message has been sent!" ;
}
I try first but work fine the only thing $_SESSION['m'] do not print NO or YES to confirm page , this is a session problem ?
I use:
<?php
session_start(); // start up your PHP session!
?>.................................................................................................... .........
<tr>
<td><div align="right" class="formfieldslabels">Send A Copy Of
This Request To Me: </div></td>
<td><div align="left" class="formfields">
<?php
echo $_SESSION['m'];
unset($_SESSION['m']); ?>
</div></td>
</tr>

mlseim
02-28-2008, 05:01 AM
You can't set sessions and assign variables and use them all
in the same "instance" of a script. By that, I mean it takes at
least one refresh to set or change the session variable ... that's
because it happens in the Header (like a cookie).

Create a separate script called "sessions.php" where you do
all of your session stuff, then it redirects back using:
header("Location: emailscript.php"); (or whatever your script is called).

That separate script does not need to "echo" anything, it just needs to
create, modify, or delete session variables and redirect back. It's operation
is invisible to the user.

lse123
02-28-2008, 09:47 AM
is this required ? please note that
processorform.php sets session var:
if (isset($_POST['emailme'])) {
mail($email,$subject,$message_customer,$headers);
$_SESSION['m'] = "An email message has been sent!" ;
} else {
$_SESSION['m'] = "No" ;
}
and confirmandemail.php echo/unset session var:
<?php
session_start(); // start up your PHP session!
?>.................................................................................................. ...........
<tr>
<td><div align="right" class="formfieldslabels">Send A Copy Of
This Request To Me: </div></td>
<td><div align="left" class="formfields">
<?php
echo $_SESSION['m'];
unset($_SESSION['m']); ?>
</div></td>
</tr>
well is needed any action, that you refer ?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum