Guys/gals...
I am running into a problem whereby I have a great piece of javascript code that mimicks multi-page forms (see www.mtsgroup.co.uk/multiPageForm.htm).....
The problem is the php file wont handle saving and sending the filled in forms by email (the emails are blank).....
The php works fine on single page forms and the multiform javascript works fine when I put a print screen action rather than a send via email.... so there must be something in the php that isn't liking retrieving the saved text and sending it via email.....
The html script is as follows
<html>
<head>
<title>Multi-Page Form</title>
<script language="JavaScript">
var currentLayer = 'page1';
function showLayer(lyr){
hideLayer(currentLayer);
document.getElementById(lyr).style.visibility = 'visible';
currentLayer = lyr;
}
function hideLayer(lyr){
document.getElementById(lyr).style.visibility = 'hidden';
}
function showValues(form){
var values = '';
var len = form.length - 1; //Leave off Submit Button
for(i=0; i<len; i++){
if(form.id.indexOf("C")!=-1||form.id.indexOf("B")!=-1)//Skip Continue and Back Buttons
continue;
values += form.id;
values += ': ';
values += form.value;
values += 'n';
}
alert(values);
}
</script>
<style>
body{
font: 10pt sans-serif;
}
.page{
position: absolute;
top: 10;
left: 100;
visibility: hidden;
}
</style>
</head>
<body>
<form id="multiForm" method="POST" action="FormToEmail.php">
<div id="page1" class="page" style="visibility:visible;">
<p>Question 1 <input type="text" id="T1" size="20"></p>
<p>Question 2 <input type="text" id="T2" size="20"></p>
<p>Question 3 <input type="text" id="T3" size="20"></p>
<p>Question 4 <input type="text" id="T4" size="20"></p>
<p>Question 5 <input type="text" id="T5" size="20"></p>
<p><input type="button" id="C1" value="Continue" onClick="showLayer('page2')"></p>
</div>
<div id="page2" class="page">
<p>Question 6 <input type="text" id="T6" size="20"></p>
<p>Question 7 <input type="text" id="T7" size="20"></p>
<p>Question 8 <input type="text" id="T8" size="20"></p>
<p>Question 9 <input type="text" id="T9" size="20"></p>
<p>Question 10 <input type="text" id="T10" size="20"></p>
<p><input type="button" id="B1" value="Go Back" onClick="showLayer('page1')"><input type="button" id="C2" value="Continue" onClick="showLayer('page3')"></p>
</div>
<div id="page3" class="page">
<p>Question 11 <input type="text" id="T11" size="20"></p>
<p>Question 12 <input type="text" id="T12" size="20"></p>
<p>Question 13 <input type="text" id="T13" size="20"></p>
<p>Question 14 <input type="text" id="T14" size="20"></p>
<p>Question 15 <input type="text" id="T15" size="20"></p>
<p><input type="button" id="B2" value="Go Back" onClick="showLayer('page2')"><input type="button" id="C3" value="Continue" onClick="showLayer('page4')"></p>
</div>
<div id="page4" class="page">
<p>Question 16 <input type="text" id="T16" size="20"></p>
<p>Question 17 <input type="text" id="T17" size="20"></p>
<p>Question 18 <input type="text" id="T18" size="20"></p>
<p>Question 19 <input type="text" id="T19" size="20"></p>
<p>Question 20 <input type="text" id="T20" size="20"></p>
<p><input type="button" id="B3" value="Go Back" onClick="showLayer('page3')"><input type="submit" value="Submit" id="submit"></p>
</div>
</form>
</body>
</html>
and the php script is as follows
<?php
error_reporting(E_ALL ^ E_NOTICE);
$my_email = "stephen.reece@mtsgroup.co.uk";
$from_email = "";
$continue = "/";
$errors = array();
// Remove $_COOKIE elements from $_REQUEST.
if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}
// Validate email field.
if(isset($_REQUEST['email']) && !empty($_REQUEST['email']))
{
$_REQUEST['email'] = trim($_REQUEST['email']);
if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['email']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($exploded_email[1],".") == 0){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = "Email address is invalid";}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}}
}
// Check referrer is from same site.
if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";}
// Check for a blank form.
function recursive_array_check_blank($element_value)
{
global $set;
if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}}
else
{
foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);}
}
}
recursive_array_check_blank($_REQUEST);
if(!$set){$errors[] = "You cannot send a blank form";}
unset($set);
// Display any errors and exit if errors exist.
if(count($errors)){foreach($errors as $value){print "$value
";} exit;}
if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "rn" : "n");}
// Build message.
function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");}
$message = build_message($_REQUEST);
$message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL."Thank you for using FormToEmail from http://FormToEmail.com";
$message = stripslashes($message);
$subject = "FormToEmail Comments";
$subject = stripslashes($subject);
if($from_email)
{
$headers = "From: " . $from_email;
$headers .= PHP_EOL;
$headers .= "Reply-To: " . $_REQUEST['email'];
}
else
{
$from_name = "";
if(isset($_REQUEST['name']) && !empty($_REQUEST['name'])){$from_name = stripslashes($_REQUEST['name']);}
$headers = "From: {$from_name} <{$_REQUEST['email']}>";
}
mail($my_email,$subject,$message,$headers);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Form To Email PHP script from FormToEmail.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
<div>
<center>
<b>Thank you <?php if(isset($_REQUEST['name'])){print stripslashes($_REQUEST['name']);} ?></b>
Your message has been sent
<p><a href="<?php print $continue; ?>">Click here to continue</a></p>
<p><b>FormToEmail</b> by <a href="http://FormToEmail.com">FormToEmail.com</a></p>
</center>
</div>
</body>
</html>
ALV List display - header width adjust
Hi,
EU VAT Package 2010
Does any one know whether SAP will be developing new reporting functionality due the new VAT rules the European Commission want to implement from 2010?
phph within href not showing php if change ? to &
Code: [Select]<a href="<?php echo $puser; ?>?m=<?php=(($m-1)<1) ? 12 : $m-1 ?>&amp;y=<?php =(($m-1)<1) ? $y-1 : $y
Passing Arguments to execlp()
I'm writing a program that mimics a unix shell. It's supposed to take commands with arguments and execute them. I'm having trouble passing in the arguments into the execlp call to correctly execute
Custom array sort? asc then desc
Any ideas how I could sort this array? I've been trying for a while. Maybe with usort, but I have no idea how... Each entry is laid out like this: ("$status||$id||$shop||$name||$date")I
What is SAP Avatar ?
Hi All,
how to export excel file in same server
My first post - php newbie, so appreciate your support.I'm currently using headers to save web page as excel file.$filename="sms.xls";header("Pragma: public");header("Expires:
Multiple Options for a Single Page
For this example I want to use the Handlers option which is under Fed Admin and all the related coding to the handlers option is found on the handlers.php page which includes a list of handlers with a
PHP Directory Listing Not working
Hey Guys,I need help, I tried a ton of directory listing scripts and they all don't work. Althogh the normal Apache Directory Indexing does work when you visit. The URL is
how to validate date using javascript
I need to validate date in textbox using javascript..The date is must be not greater than TODAY date and not less than before 3 months ..If either of these conditions is fails will show the prompt