...

View Full Version : PHP5 : errors in form processor script ?



lse123
02-21-2008, 06:35 PM
$m does not print in confirm page using <?php echo $m; ?>, well ?
also email does not delivered to $email (email of webuser) when he clicks checkbox for receive what has submitted ?


<?php

/* recipients */
$email = $_POST['email'];
$to = "info@RiverViewVilla.com";

$subject = "Booking Request for RiverViewVilla.com";
$name = $_POST['name'];
$phone = $_POST['phone'];
$comments = $_POST['comments'];
$emailme = $_POST['emailme']; // checkbox
// --------------------------------------
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$today = $_POST['today'];
$tomonth = $_POST['tomonth'];
$toyear = $_POST['toyear'];

$tsp = mktime(0, 0, 0, $month, $day, $year);
$tsd = mktime(0, 0, 0, $tomonth, $today, $toyear);
$xdays = ($tsd - $tsp)/(24*60*60);
$datep = date("l F dS, Y", $tsp);
$dated = date("l F dS, Y", $tsd); // check this H:i
// --------------------------------------
include_once ("book-confirm.php");

ob_start();
include('book-confirm.php');
$message = ob_get_clean();

ob_start();
include('email-confirm.php'); //include('book-confirm-to-customer.php');
$message_customer = ob_get_clean();

$headers = "From:info@RiverViewVilla.com";
// $headers .= "\nBcc:fontanatours@yahoo.com"
$headers .= "\nReply-To:info@RiverViewVilla.com";
$headers .= "\nContent-Type: text/html; charset=UTF-8";
$headers .= "\nMIME-Version: 1.0";

mail($to,$subject,$message,$headers);

if ($emailme == "checked") {
mail($email,$subject,$message_customer,$headers);
$m = "An email message has been sent!" ;
} else {
$m = "No" ;
}
?>

_Aerospace_Eng_
02-21-2008, 06:46 PM
$m needs to be stored in a session if you want it carried over. As to the user not getting the mail, its because you have this coded incorrectly.

if ($emailme == "checked") {
mail($email,$subject,$message_customer,$headers);
$m = "An email message has been sent!" ;
} else {
$m = "No" ;
}
It should be

if (isset($emailme)) {
mail($email,$subject,$message_customer,$headers);
$m = "An email message has been sent!" ;
} else {
$m = "No" ;
}
Here is a tutorial on php sessions. http://www.tizag.com/phpT/phpsessions.php

lse123
02-21-2008, 08:12 PM
but other vars from form do not need session , well ?

_Aerospace_Eng_
02-21-2008, 10:27 PM
If you are staying on the same page then no you don't need the session but you said it doesn't print in the confirm page which to me means its another page meaning you need a session.

lse123
02-21-2008, 10:40 PM
Why the other vars:
$name = $_POST['name'];
$phone = $_POST['phone'];
$comments = $_POST['comments'];
get print [with echo] to confirm page, and this var[$m] non print ?

_Aerospace_Eng_
02-21-2008, 10:56 PM
Because those are post variables. They get carried to whatever page they post to. $m is not a post variable. Listen to what I'm saying, you NEED a session.

lse123
02-22-2008, 02:10 PM
I make it work but
if ($emailme == "checked") {
is always true ... what to do to correct ? emailme is the name of a checkbox of
value=checkbox
and also there's the statement:
$emailme = $_POST['emailme']; // checkbox

lse123
02-22-2008, 02:16 PM
if ($emailme == "checkbox") {
mail($email,$subject,$message_customer,$headers);
$_SESSION['m'] = "An email message has been sent!" ;
} else {
$_SESSION['m'] = "No" ;
}

and


<?php session_start();
echo $_SESSION['m'];
unset($_SESSION['m']); ?>

will work the second if i include the php file in an email message ? Seems no work ?
try at(put your email): http://www.riverviewvilla.com/book.htm

Also a javascript question : I use onfocus="this.blur()" at below, to confirm page and to page come to email but does not work, I may delete the textarea data at confirm pages ...

<textarea name="comments" cols="40" rows="3" class="formfields" onfocus="this.blur()" id="comments"><?php echo $comments; ?></textarea>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum