| | |
Multiple Forms Question PHP
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
I am trying to build a page that allows the user to select multiple tasks. Each task has a form attached to it. I am using the include in my logic to determine which forms are needed. That all works fine, but I do have one problem.
If the user enters data into formA but NOT fromB and submits the data, the data is sent via email. (no databases needed). And vice versa. However, if they only fill in one form hit submit and then fill in the other form and hit submit, a duplicate email is sent.
I am trying to figure out how to unset or destroy the first form so that it isn't sent over and over.
Any ideas or suggestions???
If the user enters data into formA but NOT fromB and submits the data, the data is sent via email. (no databases needed). And vice versa. However, if they only fill in one form hit submit and then fill in the other form and hit submit, a duplicate email is sent.
I am trying to figure out how to unset or destroy the first form so that it isn't sent over and over.
Any ideas or suggestions???
If the forms are separate and the page is refreshing after each submit there shouldn't be a problem? Can we see your page?
Sarah
Sarah
There are actually 3 pages in my script.
I have tried naming the forms and that didn't seem to work. Here is the first page of code..
[php]
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title></title>
</head>
<body bgcolor='aliceblue'>
<fieldset><legend><font color='green'><b>New Employee Setup Forms</b></font></legend>
<form >
<?
if (isset($CEmail)) {
echo "CEmail is set.<br>";
}
if (isset($Enrich)) {
echo "Enrich is set.<br>";
}
if ((!$Enrich) && (!$CEmail)) {
echo "
<table align='center'>
<th colspan='2'>Select your desired tasks.<hr color='green'></th>
<tr>
</tr>
<tr>
<td align='right'><strong>Email : </strong></td>
<td>
<input type='radio' name='CEmail' value='Add'>Add,
<input type='radio' name='CEmail' value='Change'>Change,
<input type='radio' name='CEmail' value='Delete'>Delete</td>
</tr>
<tr>
<td align='right'><strong>Enrich : </strong></td>
<td>
<input type='radio' name='Enrich' value='Add'>Add,
<input type='radio' name='Enrich' value='Change'>Change,
<input type='radio' name='Enrich' value='Delete'>Delete</td>
</tr>
<tr>
<td align='center' colspan='2'><input type='submit' value='Make Changes'></td>
</tr>
</table>";
unset($CEmail);
unset($Enrich);
}
else{
if ($CEmail == 'Add') {
echo "<input type='hidden' name='CEmail' value='$CEmail'>";
include 'email.php';
unset($CEmail);
}
else if ($CEmail == 'Change') {
echo "<input type='hidden' name='CEmail' value='$CEmail'>";
include 'email.php';
unset($CEmail);
}
else if ($CEmail == 'Delete') {
echo "<input type='hidden' name='CEmail' value='$CEmail'>";
include 'email.php';
unset($CEmail);
}
else if (empty($CEmail)) {
// Do nothing
}
if ($Enrich == 'Add') {
echo "<input type='hidden' name='Enrich' value='$Enrich'>";
include 'enrich.php';
unset($Enrich);
}
else if ($Enrich == 'Change') {
echo "<input type='hidden' name='Enrich' value='$Enrich'>";
include 'changeenrich.php';
unset($Enrich);
}
else if ($Enrich == 'Delete') {
echo "<input type='hidden' name='Enrich' value='$Enrich'>";
include 'deleteenrich.php';
unset($Enrich);
}
else if (empty($Enrich)) {
// Do nothing
}
else {
echo "Sorry, but I didn't understand your instructions";
}
//unset($CEmail);
//unset($Enrich);
if (isset($CEmail)) {
echo "CEmail is set set.<br>";
}
if (isset($Enrich)) {
echo "Enrich is set set.<br>";
}
if (!$CEmail){
echo "CEmail is not set.<br>";
}
if (!$Enrich){
echo "Enrich is not set.<br>";
}
echo "<input type='submit' value='Submit Data'>";
echo "</form>";
}
////How fast was this page generated?/////////////
$timekeeper = array();
$timereport = array();
function start_track($item, $timekeeper)
{
$timeStart=gettimeofday();
$timeStart_uS=$timeStart["usec"];
$timeStart_S=$timeStart["sec"];
$item1 = $item . "_usec";
$item2 = $item . "_sec";
$timekeeper[$item1] = $timeStart_uS;
$timekeeper[$item2] = $timeStart_S;
return $timekeeper;
}
function end_track($item, $timekeeper, $timereport)
{
$timeEnd=gettimeofday();
$timeEnd_uS=$timeEnd["usec"];
$timeEnd_S=$timeEnd["sec"];
$item1 = $item . "_usec";
$item2 = $item . "_sec";
$start_uS = $timekeeper[$item1];
$start_S = $timekeeper[$item2];
$ExecTime_S = ($timeEnd_S+($timeEnd_uS/1000000))-($start_S+($start_uS/1000000));
$timereport[$item] = $ExecTime_S;
return $timereport;
}
function time_report($timereport)
{
while(list($key, $time) = each($timereport))
{
print "$key - $time sec.<br>\n";
}
}
// use these lines to perform the function calls. Make sure that you
// use the name name for the start and stop functions or it won't work
// make as many calls as you want wherever you want then use time_report
// to list all the different times
$timekeeper = start_track("This page was generated in", $timekeeper);
$timereport = end_track("This page was generated in", $timekeeper, $timereport);
// when all is said and done, call this after last end_track has been called
time_report($timereport);
?>
</fieldset>
</body>
</html>
[/php]
I have tried naming the forms and that didn't seem to work. Here is the first page of code..
[php]
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title></title>
</head>
<body bgcolor='aliceblue'>
<fieldset><legend><font color='green'><b>New Employee Setup Forms</b></font></legend>
<form >
<?
if (isset($CEmail)) {
echo "CEmail is set.<br>";
}
if (isset($Enrich)) {
echo "Enrich is set.<br>";
}
if ((!$Enrich) && (!$CEmail)) {
echo "
<table align='center'>
<th colspan='2'>Select your desired tasks.<hr color='green'></th>
<tr>
</tr>
<tr>
<td align='right'><strong>Email : </strong></td>
<td>
<input type='radio' name='CEmail' value='Add'>Add,
<input type='radio' name='CEmail' value='Change'>Change,
<input type='radio' name='CEmail' value='Delete'>Delete</td>
</tr>
<tr>
<td align='right'><strong>Enrich : </strong></td>
<td>
<input type='radio' name='Enrich' value='Add'>Add,
<input type='radio' name='Enrich' value='Change'>Change,
<input type='radio' name='Enrich' value='Delete'>Delete</td>
</tr>
<tr>
<td align='center' colspan='2'><input type='submit' value='Make Changes'></td>
</tr>
</table>";
unset($CEmail);
unset($Enrich);
}
else{
if ($CEmail == 'Add') {
echo "<input type='hidden' name='CEmail' value='$CEmail'>";
include 'email.php';
unset($CEmail);
}
else if ($CEmail == 'Change') {
echo "<input type='hidden' name='CEmail' value='$CEmail'>";
include 'email.php';
unset($CEmail);
}
else if ($CEmail == 'Delete') {
echo "<input type='hidden' name='CEmail' value='$CEmail'>";
include 'email.php';
unset($CEmail);
}
else if (empty($CEmail)) {
// Do nothing
}
if ($Enrich == 'Add') {
echo "<input type='hidden' name='Enrich' value='$Enrich'>";
include 'enrich.php';
unset($Enrich);
}
else if ($Enrich == 'Change') {
echo "<input type='hidden' name='Enrich' value='$Enrich'>";
include 'changeenrich.php';
unset($Enrich);
}
else if ($Enrich == 'Delete') {
echo "<input type='hidden' name='Enrich' value='$Enrich'>";
include 'deleteenrich.php';
unset($Enrich);
}
else if (empty($Enrich)) {
// Do nothing
}
else {
echo "Sorry, but I didn't understand your instructions";
}
//unset($CEmail);
//unset($Enrich);
if (isset($CEmail)) {
echo "CEmail is set set.<br>";
}
if (isset($Enrich)) {
echo "Enrich is set set.<br>";
}
if (!$CEmail){
echo "CEmail is not set.<br>";
}
if (!$Enrich){
echo "Enrich is not set.<br>";
}
echo "<input type='submit' value='Submit Data'>";
echo "</form>";
}
////How fast was this page generated?/////////////
$timekeeper = array();
$timereport = array();
function start_track($item, $timekeeper)
{
$timeStart=gettimeofday();
$timeStart_uS=$timeStart["usec"];
$timeStart_S=$timeStart["sec"];
$item1 = $item . "_usec";
$item2 = $item . "_sec";
$timekeeper[$item1] = $timeStart_uS;
$timekeeper[$item2] = $timeStart_S;
return $timekeeper;
}
function end_track($item, $timekeeper, $timereport)
{
$timeEnd=gettimeofday();
$timeEnd_uS=$timeEnd["usec"];
$timeEnd_S=$timeEnd["sec"];
$item1 = $item . "_usec";
$item2 = $item . "_sec";
$start_uS = $timekeeper[$item1];
$start_S = $timekeeper[$item2];
$ExecTime_S = ($timeEnd_S+($timeEnd_uS/1000000))-($start_S+($start_uS/1000000));
$timereport[$item] = $ExecTime_S;
return $timereport;
}
function time_report($timereport)
{
while(list($key, $time) = each($timereport))
{
print "$key - $time sec.<br>\n";
}
}
// use these lines to perform the function calls. Make sure that you
// use the name name for the start and stop functions or it won't work
// make as many calls as you want wherever you want then use time_report
// to list all the different times
$timekeeper = start_track("This page was generated in", $timekeeper);
$timereport = end_track("This page was generated in", $timekeeper, $timereport);
// when all is said and done, call this after last end_track has been called
time_report($timereport);
?>
</fieldset>
</body>
</html>
[/php]
Here is the "email.php" page.
[php]
<?
$HelpdeskEmail = "emailaddy@company.com";
$ip = $_SERVER['REMOTE_ADDR']; //Get IP Address
$CurrentDate=date("l dS of F Y h:i:s A"); //Set Current Date (Friday 25th of March 2005 09:46:28 AM)
if ($CEmail == "Add"){
echo "
<input type='hidden' name='FirstName' value='$FirstName'>
<input type='hidden' name='LastName' value='$LastName'>
<input type='hidden' name='Submitter' value='$Submitter'>
<input type='hidden' name='Email' value='$Email'>";
AddEmail();
}
else if ($CEmail == "Change"){
echo "
<input type='hidden' name='FirstName' value='$FirstName'>
<input type='hidden' name='LastName' value='$LastName'>
<input type='hidden' name='Submitter' value='$Submitter'>
<input type='hidden' name='Email' value='$Email'>";
ChangeEmail();
}
else if ($CEmail == "Delete"){
echo "
<input type='hidden' name='FirstName' value='$FirstName'>
<input type='hidden' name='LastName' value='$LastName'>
<input type='hidden' name='Submitter' value='$Submitter'>
<input type='hidden' name='Email' value='$Email'>";
DeleteEmail();
}
else if (!$CEmail) {
echo "No Email Changes Necessary";
}
Function AddEmail(){
global $LastName, $FirstName, $Submitter, $Email, $HelpdeskEmail;
if (empty($LastName)) {
echo "
<table align='center'>
<tr>
<th>You must complete the entire form.</th>
</tr>
<tr>
<td>First Name:</td>
<td><input type='text' name='FirstName' value='$FirstName'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text' name='LastName' value='$LastName'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Submitted By:</td>
<td><input type='text' name='Submitter' value='$Submitter'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Your Email Address:</td>
<td><input type='text' name='Email' value='$Email'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td colspan='3' align='center'>$CurrentDate</td>
</tr>
</table>";
}
else {
AddEmailVerify();
}
}
Function ChangeEmail(){
global $LastName, $FirstName, $Submitter, $Email, $HelpdeskEmail;
if (empty($LastName)) {
echo "
<table align='center'>
<tr>
<th>You must complete the entire form.</th>
</tr>
<tr>
<td>First Name:</td>
<td><input type='text' name='FirstName' value='$FirstName'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text' name='LastName' value='$LastName'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Submitted By:</td>
<td><input type='text' name='Submitter' value='$Submitter'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Your Email Address:</td>
<td><input type='text' name='Email' value='$Email'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td colspan='3' align='center'>$CurrentDate</td>
</tr>
<tr>
<td colspan='3' align='center'><input type='submit' value='Submit Data'>
<input type='reset' value='Reset'></td>
</tr>
</table>";
}
else {
ChangeEmailVerify();
}
}
Function DeleteEmail(){
global $LastName, $FirstName, $Submitter, $Email, $HelpdeskEmail;
if (empty($LastName)) {
echo "
<table align='center'>
<tr>
<th>You must complete the entire form.</th>
</tr>
<tr>
<td>First Name:</td>
<td><input type='text' name='FirstName' value='$FirstName'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text' name='LastName' value='$FirstName'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Submitted By:</td>
<td><input type='text' name='Submitter' value='Submitter'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Your Email Address:</td>
<td><input type='text' name='Email' value='$Email'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td colspan='3' align='center'>$CurrentDate</td>
</tr>
<tr>
<td colspan='3' align='center'><input type='submit' value='Submit Data'>
<input type='reset' value='Reset'></td>
</tr>
</table>";
}
else {
DeleteEmailVerify();
}
}
Function AddEmailVerify(){
global $FirstName, $LastName, $Submitter, $Email, $ip, $CurrentDate, $HelpdeskEmail;
// Remove white spaces and leading space from data entry
$Group=trim($Group);
$FirstName=trim($FirstName);
$Supervisor=trim($Supervisor);
$Submitter=trim($Submitter);
$Email=trim($Email);
$Submitter-trim($Submitter);
//Verify that the form has been filled out.
if ((!$FirstName) || (!$LastName) || (!$Submitter) || (!$Email)) {
echo "<h1 align='center'>You did not submit the following required information! <br />
</h1><br />";
if(!$FirstName){
echo "<p>First Name is a required field. Please enter it now. <input type='text' name='FirstName'> </p>";
}
if(!$LastName){
echo "<p>Last Name is a required field. Please enter it now. <input type='text' name='LastName'> ></p>";
}
if(!$Submitter){
echo "<p>Your Name is required field. Please enter it now. <input type='text' name='Submitter'> </p>";
}
if(!$Email){
echo "<p>Your Email Address is required field. Please enter it now. <input type='text' name='Email'> </p>";
}
echo "<h1 align='center'><input type='submit' value='Update Data'></h1>";
}
else {
echo "
<table align='center'>
<tr>
<th colspan='2'>You have submitted the following information to the helpdesk.</th>
</tr>
<tr>
<td>First Name:</td>
<td><input type='text' name='FirstName' value='$FirstName'></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text' name='LastName' value='$LastName'></td>
</tr>
<tr>
<td colspan='2' align='center'>$CurrentDate</td>
</tr>
<tr>
<td colspan='2' align='center'>The IP address is <font color='red'><strong>$ip</strong></font></td>
</tr>
</table>";
// Send Message
$to = ("$Email, $HelpdeskEmail");
//$headers = "MIME-Version: 1.0\r\n";
//$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers = "From: $Email\n";
$subject = "Add Email Address";
$message = "--------Employee Affected--------\n"
."First Name: ".$FirstName."\n"
."Last Name: ".$LastName."\n"
."\n\n--------Submitter Information--------\n"
."Submitter: ".$Submitter."\n"
."Email: ".$Email."\n\n\n"
."\n\n--------Stats--------\n"
."Sent from ".$ip."\n"
."Current Date & Time: ".$CurrentDate."\n";
//In case any of our lines are larger than 70 characters, we should use wordwrap()
//$message = wordwrap($message, 70);
// Send
mail($to, $subject, $message, $headers);
echo "<table align='center'>
<tr>
<th>Message has been sent</th>
</tr>
</table>";
}
unset($CEmail);
unset($LastName);
unset($FirstName);
unset($Submitter);
unset($Email);
unset($HelpdeskEmail);
unset($to);
unset($subject);
unset($message);
unset($headers);
}
Function ChangeEmailVerify(){
global $FirstName, $LastName, $Submitter, $Email, $ip, $CurrentDate, $HelpdeskEmail;
// Remove white spaces and leading space from data entry
$Group=trim($Group);
$FirstName=trim($FirstName);
$Supervisor=trim($Supervisor);
$Submitter=trim($Submitter);
$Email=trim($Email);
$Submitter-trim($Submitter);
//Verify that the form has been filled out.
if ((!$FirstName) || (!$LastName) || (!$Submitter) || (!$Email)) {
echo "<h1 align='center'>You did not submit the following required information! <br />
</h1><br />";
if(!$FirstName){
echo "<p>First Name is a required field. Please enter it now. <input type='text' name='FirstName'> </p>";
}
if(!$LastName){
echo "<p>Last Name is a required field. Please enter it now. <input type='text' name='LastName'> ></p>";
}
if(!$Submitter){
echo "<p>Your Name is required field. Please enter it now. <input type='text' name='Submitter'> </p>";
}
if(!$Email){
echo "<p>Your Email Address is required field. Please enter it now. <input type='text' name='Email'> </p>";
}
echo "<input type='submit' value='Update Data'>";
}
else {
echo "
<table align='center'>
<tr>
<th colspan='2'>You have submitted the following information to the helpdesk.</th>
</tr>
<tr>
<td>First Name:</td>
<td><input type='text' name='FirstName' value='$FirstName'></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text name='LastName' value='$LastName'></td>
</tr>
<tr>
<td colspan='2' align='center'>$CurrentDate</td>
</tr>
<tr>
<td colspan='2' align='center'>The IP address is <font color='red'><strong>$ip</strong></font></td>
</tr>
</table>";
// Send Message
$to = ("$Email, $HelpdeskEmail");
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $Email\n";
$subject = "Change Email Address";
$message = "--------Employee Affected--------\n"
."First Name: ".$FirstName."\n"
."Last Name: ".$LastName."\n"
."\n\n--------PHONE--------\n"
."Submitter: ".$Submitter."\n"
."Email: ".$Email."\n\n\n"
."\n\n--------Stats--------\n"
."Sent from ".$ip."\n"
."Current Date & Time: ".$CurrentDate."\n";
//In case any of our lines are larger than 70 characters, we should use wordwrap()
//$message = wordwrap($message, 70);
// Send
mail($to, $subject, $message, $headers);
echo "<table align='center'>
<tr>
<th>Message has been sent</th>
</tr>
</table>";
}
unset($CEmail);
unset($LastName);
unset($FirstName);
unset($Submitter);
unset($Email);
unset($HelpdeskEmail);
unset($to);
unset($subject);
unset($message);
unset($headers);
}
Function DeleteEmailVerify(){
global $EFirstName, $ELastName, $ESubmitter, $EEmail, $ip, $CurrentDate, $HelpdeskEmail;
// Remove white spaces and leading space from data entry
$Group=trim($Group);
$FirstName=trim($FirstName);
$Supervisor=trim($Supervisor);
$Submitter=trim($Submitter);
$Email=trim($Email);
$Submitter-trim($Submitter);
//Verify that the form has been filled out.
if ((!$FirstName) || (!$LastName) || (!$Submitter) || (!$Email)) {
echo "<h1 align='center'>You did not submit the following required information! <br />
</h1><br/>";
if(!$FirstName){
echo "<p>First Name is a required field. Please enter it now. <input type='text' name='FirstName'> </p>";
}
if(!$LastName){
echo "<p>Last Name is a required field. Please enter it now. <input type='text' name='LastName'> ></p>";
}
if(!$Submitter){
echo "<p>Your Name is required field. Please enter it now. <input type='text' name='Submitter'> </p>";
}
if(!$Email){
echo "<p>Your Email Address is required field. Please enter it now. <input type='text' name='Email'> </p>";
}
echo "<input type='submit' value='Update Data'>";
}
else {
echo "
<table align='center'>
<tr>
<th colspan='2'>You have submitted the following information to the helpdesk.</th>
</tr>
<tr>
<td>First Name:</td>
<td><input type='text' name='FirstName' value='$FirstName'></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text name='LastName' value='$LastName'></td>
</tr>
<tr>
<td colspan='2' align='center'>$CurrentDate</td>
</tr>
<tr>
<td colspan='2' align='center'>The IP address is <font color='red'><strong>$ip</strong></font></td>
</tr>
</table>";
// Send Message
$to = ("$Email, $HelpdeskEmail");
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $Email\n";
$subject = "Delete Email Address";
$message = "--------Employee Affected--------\n"
."First Name: ".$FirstName."\n"
."Last Name: ".$LastName."\n"
."\n\n--------PHONE--------\n"
."Submitter: ".$Submitter."\n"
."Email: ".$Email."\n\n\n"
."\n\n--------Stats--------\n"
."Sent from ".$ip."\n"
."Current Date & Time: ".$CurrentDate."\n";
//In case any of our lines are larger than 70 characters, we should use wordwrap()
//$message = wordwrap($message, 70);
// Send
mail($to, $subject, $message, $headers);
echo "<table align='center'>
<tr>
<th>Message has been sent</th>
</tr>
</table>";
}
}
unset($LastName);
unset($FirstName);
unset($Submitter);
unset($Email);
unset($HelpdeskEmail);
unset($to);
unset($subject);
unset($message);
unset($headers);
//<table align='center' border='3' bgcolor='aliceblue' frame='box' bordercolor='blue' rules='none'>
// <th colspan='2'><h3>Add Email Address</h3></th>
// <tr>
// <td>Employee First Name:</td>
// <td><input type='text' name='FirstName' value='$FirstName' size='40'></td>
// </tr>
// <tr>
// <td>Employee Last Name:</td>
// <td><input type='text' name='LastName' value='$LastName' size='40'></td>
// </tr>
// <tr>
// <td colspan='2'><hr color='blue' width='75%'></td>
// </tr>
// <tr>
// <td>Submitted By:</td>
// <td><input type='text' name='Submitter' value='$Submitter' size='40'></td>
// </tr>
// <tr>
// <td>Your Email Address:</td>
// <td><input type='text' name='Email' value='$Email' size='40'></td>
// </tr>
// <tr>
// <td colspan='2' align='center'>$CurrentDate</td>
// </tr>
// <tr>
// <td colspan='2' align='center'>The IP address is <font color='red'><strong>$ip</strong></font></td>
// </tr>
// </table>
?>[/php]
[php]
<?
$HelpdeskEmail = "emailaddy@company.com";
$ip = $_SERVER['REMOTE_ADDR']; //Get IP Address
$CurrentDate=date("l dS of F Y h:i:s A"); //Set Current Date (Friday 25th of March 2005 09:46:28 AM)
if ($CEmail == "Add"){
echo "
<input type='hidden' name='FirstName' value='$FirstName'>
<input type='hidden' name='LastName' value='$LastName'>
<input type='hidden' name='Submitter' value='$Submitter'>
<input type='hidden' name='Email' value='$Email'>";
AddEmail();
}
else if ($CEmail == "Change"){
echo "
<input type='hidden' name='FirstName' value='$FirstName'>
<input type='hidden' name='LastName' value='$LastName'>
<input type='hidden' name='Submitter' value='$Submitter'>
<input type='hidden' name='Email' value='$Email'>";
ChangeEmail();
}
else if ($CEmail == "Delete"){
echo "
<input type='hidden' name='FirstName' value='$FirstName'>
<input type='hidden' name='LastName' value='$LastName'>
<input type='hidden' name='Submitter' value='$Submitter'>
<input type='hidden' name='Email' value='$Email'>";
DeleteEmail();
}
else if (!$CEmail) {
echo "No Email Changes Necessary";
}
Function AddEmail(){
global $LastName, $FirstName, $Submitter, $Email, $HelpdeskEmail;
if (empty($LastName)) {
echo "
<table align='center'>
<tr>
<th>You must complete the entire form.</th>
</tr>
<tr>
<td>First Name:</td>
<td><input type='text' name='FirstName' value='$FirstName'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text' name='LastName' value='$LastName'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Submitted By:</td>
<td><input type='text' name='Submitter' value='$Submitter'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Your Email Address:</td>
<td><input type='text' name='Email' value='$Email'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td colspan='3' align='center'>$CurrentDate</td>
</tr>
</table>";
}
else {
AddEmailVerify();
}
}
Function ChangeEmail(){
global $LastName, $FirstName, $Submitter, $Email, $HelpdeskEmail;
if (empty($LastName)) {
echo "
<table align='center'>
<tr>
<th>You must complete the entire form.</th>
</tr>
<tr>
<td>First Name:</td>
<td><input type='text' name='FirstName' value='$FirstName'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text' name='LastName' value='$LastName'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Submitted By:</td>
<td><input type='text' name='Submitter' value='$Submitter'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Your Email Address:</td>
<td><input type='text' name='Email' value='$Email'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td colspan='3' align='center'>$CurrentDate</td>
</tr>
<tr>
<td colspan='3' align='center'><input type='submit' value='Submit Data'>
<input type='reset' value='Reset'></td>
</tr>
</table>";
}
else {
ChangeEmailVerify();
}
}
Function DeleteEmail(){
global $LastName, $FirstName, $Submitter, $Email, $HelpdeskEmail;
if (empty($LastName)) {
echo "
<table align='center'>
<tr>
<th>You must complete the entire form.</th>
</tr>
<tr>
<td>First Name:</td>
<td><input type='text' name='FirstName' value='$FirstName'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text' name='LastName' value='$FirstName'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Submitted By:</td>
<td><input type='text' name='Submitter' value='Submitter'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td>Your Email Address:</td>
<td><input type='text' name='Email' value='$Email'></td>
<td><font face='comic' color='red'><i>Required</i></font></td>
</tr>
<tr>
<td colspan='3' align='center'>$CurrentDate</td>
</tr>
<tr>
<td colspan='3' align='center'><input type='submit' value='Submit Data'>
<input type='reset' value='Reset'></td>
</tr>
</table>";
}
else {
DeleteEmailVerify();
}
}
Function AddEmailVerify(){
global $FirstName, $LastName, $Submitter, $Email, $ip, $CurrentDate, $HelpdeskEmail;
// Remove white spaces and leading space from data entry
$Group=trim($Group);
$FirstName=trim($FirstName);
$Supervisor=trim($Supervisor);
$Submitter=trim($Submitter);
$Email=trim($Email);
$Submitter-trim($Submitter);
//Verify that the form has been filled out.
if ((!$FirstName) || (!$LastName) || (!$Submitter) || (!$Email)) {
echo "<h1 align='center'>You did not submit the following required information! <br />
</h1><br />";
if(!$FirstName){
echo "<p>First Name is a required field. Please enter it now. <input type='text' name='FirstName'> </p>";
}
if(!$LastName){
echo "<p>Last Name is a required field. Please enter it now. <input type='text' name='LastName'> ></p>";
}
if(!$Submitter){
echo "<p>Your Name is required field. Please enter it now. <input type='text' name='Submitter'> </p>";
}
if(!$Email){
echo "<p>Your Email Address is required field. Please enter it now. <input type='text' name='Email'> </p>";
}
echo "<h1 align='center'><input type='submit' value='Update Data'></h1>";
}
else {
echo "
<table align='center'>
<tr>
<th colspan='2'>You have submitted the following information to the helpdesk.</th>
</tr>
<tr>
<td>First Name:</td>
<td><input type='text' name='FirstName' value='$FirstName'></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text' name='LastName' value='$LastName'></td>
</tr>
<tr>
<td colspan='2' align='center'>$CurrentDate</td>
</tr>
<tr>
<td colspan='2' align='center'>The IP address is <font color='red'><strong>$ip</strong></font></td>
</tr>
</table>";
// Send Message
$to = ("$Email, $HelpdeskEmail");
//$headers = "MIME-Version: 1.0\r\n";
//$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers = "From: $Email\n";
$subject = "Add Email Address";
$message = "--------Employee Affected--------\n"
."First Name: ".$FirstName."\n"
."Last Name: ".$LastName."\n"
."\n\n--------Submitter Information--------\n"
."Submitter: ".$Submitter."\n"
."Email: ".$Email."\n\n\n"
."\n\n--------Stats--------\n"
."Sent from ".$ip."\n"
."Current Date & Time: ".$CurrentDate."\n";
//In case any of our lines are larger than 70 characters, we should use wordwrap()
//$message = wordwrap($message, 70);
// Send
mail($to, $subject, $message, $headers);
echo "<table align='center'>
<tr>
<th>Message has been sent</th>
</tr>
</table>";
}
unset($CEmail);
unset($LastName);
unset($FirstName);
unset($Submitter);
unset($Email);
unset($HelpdeskEmail);
unset($to);
unset($subject);
unset($message);
unset($headers);
}
Function ChangeEmailVerify(){
global $FirstName, $LastName, $Submitter, $Email, $ip, $CurrentDate, $HelpdeskEmail;
// Remove white spaces and leading space from data entry
$Group=trim($Group);
$FirstName=trim($FirstName);
$Supervisor=trim($Supervisor);
$Submitter=trim($Submitter);
$Email=trim($Email);
$Submitter-trim($Submitter);
//Verify that the form has been filled out.
if ((!$FirstName) || (!$LastName) || (!$Submitter) || (!$Email)) {
echo "<h1 align='center'>You did not submit the following required information! <br />
</h1><br />";
if(!$FirstName){
echo "<p>First Name is a required field. Please enter it now. <input type='text' name='FirstName'> </p>";
}
if(!$LastName){
echo "<p>Last Name is a required field. Please enter it now. <input type='text' name='LastName'> ></p>";
}
if(!$Submitter){
echo "<p>Your Name is required field. Please enter it now. <input type='text' name='Submitter'> </p>";
}
if(!$Email){
echo "<p>Your Email Address is required field. Please enter it now. <input type='text' name='Email'> </p>";
}
echo "<input type='submit' value='Update Data'>";
}
else {
echo "
<table align='center'>
<tr>
<th colspan='2'>You have submitted the following information to the helpdesk.</th>
</tr>
<tr>
<td>First Name:</td>
<td><input type='text' name='FirstName' value='$FirstName'></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text name='LastName' value='$LastName'></td>
</tr>
<tr>
<td colspan='2' align='center'>$CurrentDate</td>
</tr>
<tr>
<td colspan='2' align='center'>The IP address is <font color='red'><strong>$ip</strong></font></td>
</tr>
</table>";
// Send Message
$to = ("$Email, $HelpdeskEmail");
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $Email\n";
$subject = "Change Email Address";
$message = "--------Employee Affected--------\n"
."First Name: ".$FirstName."\n"
."Last Name: ".$LastName."\n"
."\n\n--------PHONE--------\n"
."Submitter: ".$Submitter."\n"
."Email: ".$Email."\n\n\n"
."\n\n--------Stats--------\n"
."Sent from ".$ip."\n"
."Current Date & Time: ".$CurrentDate."\n";
//In case any of our lines are larger than 70 characters, we should use wordwrap()
//$message = wordwrap($message, 70);
// Send
mail($to, $subject, $message, $headers);
echo "<table align='center'>
<tr>
<th>Message has been sent</th>
</tr>
</table>";
}
unset($CEmail);
unset($LastName);
unset($FirstName);
unset($Submitter);
unset($Email);
unset($HelpdeskEmail);
unset($to);
unset($subject);
unset($message);
unset($headers);
}
Function DeleteEmailVerify(){
global $EFirstName, $ELastName, $ESubmitter, $EEmail, $ip, $CurrentDate, $HelpdeskEmail;
// Remove white spaces and leading space from data entry
$Group=trim($Group);
$FirstName=trim($FirstName);
$Supervisor=trim($Supervisor);
$Submitter=trim($Submitter);
$Email=trim($Email);
$Submitter-trim($Submitter);
//Verify that the form has been filled out.
if ((!$FirstName) || (!$LastName) || (!$Submitter) || (!$Email)) {
echo "<h1 align='center'>You did not submit the following required information! <br />
</h1><br/>";
if(!$FirstName){
echo "<p>First Name is a required field. Please enter it now. <input type='text' name='FirstName'> </p>";
}
if(!$LastName){
echo "<p>Last Name is a required field. Please enter it now. <input type='text' name='LastName'> ></p>";
}
if(!$Submitter){
echo "<p>Your Name is required field. Please enter it now. <input type='text' name='Submitter'> </p>";
}
if(!$Email){
echo "<p>Your Email Address is required field. Please enter it now. <input type='text' name='Email'> </p>";
}
echo "<input type='submit' value='Update Data'>";
}
else {
echo "
<table align='center'>
<tr>
<th colspan='2'>You have submitted the following information to the helpdesk.</th>
</tr>
<tr>
<td>First Name:</td>
<td><input type='text' name='FirstName' value='$FirstName'></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text name='LastName' value='$LastName'></td>
</tr>
<tr>
<td colspan='2' align='center'>$CurrentDate</td>
</tr>
<tr>
<td colspan='2' align='center'>The IP address is <font color='red'><strong>$ip</strong></font></td>
</tr>
</table>";
// Send Message
$to = ("$Email, $HelpdeskEmail");
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $Email\n";
$subject = "Delete Email Address";
$message = "--------Employee Affected--------\n"
."First Name: ".$FirstName."\n"
."Last Name: ".$LastName."\n"
."\n\n--------PHONE--------\n"
."Submitter: ".$Submitter."\n"
."Email: ".$Email."\n\n\n"
."\n\n--------Stats--------\n"
."Sent from ".$ip."\n"
."Current Date & Time: ".$CurrentDate."\n";
//In case any of our lines are larger than 70 characters, we should use wordwrap()
//$message = wordwrap($message, 70);
// Send
mail($to, $subject, $message, $headers);
echo "<table align='center'>
<tr>
<th>Message has been sent</th>
</tr>
</table>";
}
}
unset($LastName);
unset($FirstName);
unset($Submitter);
unset($Email);
unset($HelpdeskEmail);
unset($to);
unset($subject);
unset($message);
unset($headers);
//<table align='center' border='3' bgcolor='aliceblue' frame='box' bordercolor='blue' rules='none'>
// <th colspan='2'><h3>Add Email Address</h3></th>
// <tr>
// <td>Employee First Name:</td>
// <td><input type='text' name='FirstName' value='$FirstName' size='40'></td>
// </tr>
// <tr>
// <td>Employee Last Name:</td>
// <td><input type='text' name='LastName' value='$LastName' size='40'></td>
// </tr>
// <tr>
// <td colspan='2'><hr color='blue' width='75%'></td>
// </tr>
// <tr>
// <td>Submitted By:</td>
// <td><input type='text' name='Submitter' value='$Submitter' size='40'></td>
// </tr>
// <tr>
// <td>Your Email Address:</td>
// <td><input type='text' name='Email' value='$Email' size='40'></td>
// </tr>
// <tr>
// <td colspan='2' align='center'>$CurrentDate</td>
// </tr>
// <tr>
// <td colspan='2' align='center'>The IP address is <font color='red'><strong>$ip</strong></font></td>
// </tr>
// </table>
?>[/php]
And finally the "enrich.php" script. This page is very simple and only for my testing... it will change.
[php]
<?
if (empty($EnrichName)){
echo "
<table>
<tr>
<td>Add Enrich Name:<input type='text' name='EnrichName' value='$EnrichName'></td>
</tr>
</table>";
}
else {
echo "You have entered ".$EnrichName.". (Enrich)";
}
/* ---------------------
Declare Variable(s)
--------------------- */
$name; // Represents the name of the elements in $HTTP_POST_VARS
$value; // Represents the value of the elements in $HTTP_POST_VARS
// ---------------------
// Do while there is an element in $HTTP_POST_VARS...
while (list($name, $value) = each($HTTP_POST_VARS))
/* ...get the name and value of the element and use it to construct a hidden input field.
Then go back to the beginning of the loop and do the same thing with the next element. */
{
echo "<input type=\"hidden\" value=\"$value\" name=\"$name\">\n";
}
?>[/php]
[php]
<?
if (empty($EnrichName)){
echo "
<table>
<tr>
<td>Add Enrich Name:<input type='text' name='EnrichName' value='$EnrichName'></td>
</tr>
</table>";
}
else {
echo "You have entered ".$EnrichName.". (Enrich)";
}
/* ---------------------
Declare Variable(s)
--------------------- */
$name; // Represents the name of the elements in $HTTP_POST_VARS
$value; // Represents the value of the elements in $HTTP_POST_VARS
// ---------------------
// Do while there is an element in $HTTP_POST_VARS...
while (list($name, $value) = each($HTTP_POST_VARS))
/* ...get the name and value of the element and use it to construct a hidden input field.
Then go back to the beginning of the loop and do the same thing with the next element. */
{
echo "<input type=\"hidden\" value=\"$value\" name=\"$name\">\n";
}
?>[/php]
![]() |
Similar Threads
- Side-by-side forms? (HTML and CSS)
- HOWTO: Share an SQL Connection between multiple forms within the same project (C#)
- Windows Forms Question (C#)
- Please Help me in finding multiple choice question with answer on data structure. (Computer Science)
Other Threads in the PHP Forum
- Previous Thread: PHP poll
- Next Thread: PHP Session
| Thread Tools | Search this Thread |
301 access apache api array beginner binary broken button cakephp checkbox class clean cms code countingeverycharactersfromastring crack cron curl database date decode directory display dissertation dropdown dynamic echo email error fairness file files folder form forms function functions google href htaccess html image include insert integration ip javascript joomla limit link login mail match md5 menu methods mlm multiple mysql newsletters oop pageing pagerank paypal pdf php problem protocol query radio random recursion remote script search secure server sessions simple sms soap source space spam sql syntax system table tutorial update upload url validator variable video virus votedown web youtube





