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>
Quick Syntax Question
Hi folks,I'm getting the following error: "unexpected T_LNUMBER". I'm trying to build a dynamic table in PHP it was working great until I attempted to include a java reference in one of my
Using cURL to PUT
Can somebody help with the correct php code to make a cURL PUT request. Here is a sample of code below that uses POST, but I need to modify this one so that it uses PUT instead.Code: <?php
empty() error
Why doesCode: empty($USER_ID = $_SESSION["USER_ID"])create this error...Parse error: syntax error, unexpected '=', expecting ')' in /home3/finestto/public_html/index.php on line 17
Redistributing dependent dlls
Hai all ,I have created an application in VC++ using VS2008 in a development machine which runs on Vista, now i need to run that application in a target machine which runs on windows XP SP2 which does
How to Create a Dynamic table
col1 col2 date1 date2 date3 date4..........a b v1 v2 v3 v4c d v5 v6 v7 v8e f v9 v10 v11 v12 . .
Any help with my email script?
I have an email script, I have not tested it, although someone tested it for me and said it worked fine. I started to make modifications to the code after using the basic structure. This is my HTML
weird problem
last time, i did post a topic concerning why my page sometime will load as blank page when using IE. someone has told me that it might be my hosting server problem, too slow...but, now after testing
Problem with passing variables
I'm not really a php programmer so I'm really struggling with this issue. I have a banner script that is supposed to send people to an affiliate site and pass the parameters along with it.For
firefox wouldnt stream mp3 files completely from my php page
hi everyone,I have a php file trying to read and stream mp3 files. It works fine in IE but my problem is Firefox streams only 3 seconds of them.$direction =
remove innitial
and
tagsi am using tiny_mce as a text editor for my CMS.buy now the problem is it add <p> tag with dataso while retrieving the data for front end i get an extra space. so there is any why that i