Hello All
I am new to this forum. I am trying to pass variables from page to page in order to maintain a state so I can use information users entered to interact with them and send email as appropriate. I added comments in the code below that explains what I am trying to achieve. At the moment my first hurdle is getting all the values from the form in one variable and then trimming and cleaning it as necessary but having no luck.
This the contact.shtml form:
// (1)
// CheckAll() is a javascript function and it works ok.
<?
include ("cleaner.php);
?>
<form action="php/validate.php" method="POST" NAME="contact" onSubmit="return checkAll()">
// usual form structure follows here no typos, all is ok.
//Now cleaner.php looks like this:
function clean_it_out($formVariables)
{
$formVariables = trim($formVariables);
$formVariables = htmlentities($formVariables);
$formVariables = strip_tags($formVariables);
return $formVariables;
}
This to validate the form server side and clean out htm codes:
// (2)
// Validate page: This is where I am having problems
// I am trying to grab all the user inputs over 15 in the form
// input fields and put them in one variabe and then strip out
// the dangerous stuff.
for ($_POST as $variable_name => $value)
{
$formVariables[$variable_names} = clean_it_out ($value, 50);
}
extract ($_POST, XTR_PREFIX_ALL, '$formVariables');
// Validate rest of form inputs as normal here ...
// Then at the bottom of the valaidate.php page, output what
// visitor entered to next php page:
Header("Location: valinput.php?Firstname=$FirstName&Surname=$Surname");
This is to output what the user entered and email the form to a desired email address:
// (3)
//In the output.php I use the print command to output everything
// neatly in a table for the user to see, then when user press send,
// it emails the user inputs depending on which country they
// selected in the contact.shtml page:
print "<table cellpadding=0 blah blah>";
print "<tr><td>Blah blab blah</td></tr>";
// and so the print commands goes on...
// Then depending on what country the user selected send an
// email to the correct email address:
if ($formVariables[Option"] == "USA")
{
echo "<form action=\"email_usa.php\" method=\"post\"> ";
}
if ($formVariables["Option"] == "Canada")
{
echo "<form action=\"email_can.php\" method=\"post\"> ";
}
if ($formVariables["Option"] == "UK")
{
echo "<form action=\"email_uk.php\" method=\"post\"> ";
}
$FirstName;
$value;
while (list($Firstname, $value) = each($_POST))
{
echo "<input type=\"hidden\" value=\"$value\" Name=\"$Firstname\">\n";
}
//Havent reached the thank_you.php page yet to output a confirmation
// that email sent successfull. That's a simple html page I guess