PDA

View Full Version : PHP code for form & php file


AngieMeekie
08-21-2008, 08:14 PM
HI -I posted this morning but didn't get any replies, BUT I think I have it figured out. Assuming that the server supports PHP, is this code correct for subitting the form to the email address specified in the following "sendresults.php." ???

WEB PAGE CODE
__________________________

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>R&amp;L Digital Photo Lab: Place A Reorder</title>
<style type="text/css">
<!--
body,td,th {
color: #000000;
}
#links {
position:absolute;
width:204px;
height:235px;
z-index:1;
left: 53px;
top: 303px;
visibility: visible;
}
#logo {
position:absolute;
width:200px;
height:60px;
z-index:2;
left: 73px;
top: 24px;
}
#welcome {
position:absolute;
width:550px;
height:81px;
z-index:3;
left: 252px;
top: 39px;
}
#Layer4 {
position:absolute;
width:200px;
height:115px;
z-index:4;
left: 508px;
top: 193px;
}
#Layer1 {
position:absolute;
width:200px;
height:115px;
z-index:5;
left: 513px;
top: 187px;
}
body {
background-image: url();
background-repeat: no-repeat;
background-color: #FFFFFF;
}
#Layer2 {
position:absolute;
width:200px;
height:115px;
z-index:5;
left: 290px;
top: 316px;
}
#Layer3 {
position:absolute;
width:67px;
height:61px;
z-index:6;
left: 357px;
top: 534px;
}
#Layer5 {
position:absolute;
width:174px;
height:91px;
z-index:7;
left: 310px;
top: 435px;
}
#Layer6 {
position:absolute;
width:163px;
height:115px;
z-index:8;
left: 322px;
top: 172px;
}
#Layer7 {
position:absolute;
width:687px;
height:24px;
z-index:9;
left: 257px;
top: 133px;
}
#Layer8 {
position:absolute;
width:694px;
height:29px;
z-index:9;
left: 271px;
top: 108px;
}
#Layer9 {
position:absolute;
width:210px;
height:30px;
z-index:10;
left: 735px;
top: 151px;
}
#Layer10 {
position:absolute;
width:176px;
height:170px;
z-index:2;
left: 32px;
top: 29px;
visibility: visible;
}
#Layer11 {
position:absolute;
width:168px;
height:41px;
z-index:3;
left: 502px;
top: 77px;
visibility: visible;
}
.style16 {color: #000000; font-family: "Book Antiqua"; font-weight: bold; font-style: italic; }
.style17 {font-family: "Book Antiqua"; font-weight: bold; font-style: italic; }
#Layer12 {
position:absolute;
width:821px;
height:32px;
z-index:5;
left: 270px;
top: 303px;
}
#Layer13 {
position:absolute;
width:819px;
height:22px;
z-index:6;
left: 270px;
top: 360px;
}
#Layer14 {
position:absolute;
width:484px;
height:23px;
z-index:7;
left: 724px;
top: 463px;
}
#Layer15 {
position:absolute;
width:200px;
height:0px;
z-index:8;
left: 833px;
top: 519px;
}
#Layer16 {
position:absolute;
width:561px;
height:0px;
z-index:9;
left: 265px;
top: 573px;
}
#Layer17 {
position:absolute;
width:200px;
height:115px;
z-index:4;
left: 115px;
top: 610px;
}
#Layer18 {
position:absolute;
width:593px;
height:63px;
z-index:10;
left: 267px;
top: 905px;
}
#Layer19 {
position:absolute;
width:200px;
height:14px;
z-index:10;
left: 318px;
top: 900px;
}
#Layer20 {
position:absolute;
width:227px;
height:87px;
z-index:11;
left: 959px;
top: 699px;
visibility: visible;
}
#Layer21 {
position:absolute;
width:227px;
height:70px;
z-index:12;
left: 960px;
top: 814px;
}
#Layer22 {
position:absolute;
width:699px;
height:129px;
z-index:6;
left: 305px;
top: 148px;
}
.style33 {color: #0000CC; font-family: "Book Antiqua"; font-weight: bold; font-style: italic; }
a:link {
color: #0000CC;
}
a:visited {
color: #CC00CC;
}
#Layer23 {
position:absolute;
width:794px;
height:422px;
z-index:4;
left: 278px;
top: -114px;
}
.style34 {font-size: small}
-->
</style>
<script type="text/javascript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>
<body>
<div align="left">
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p>&nbsp;</p>
<div id="links">
<table width="200" border="0">
<tr>
<td><span class="style16"><a href="home.html">Home</a></span>
<div id="Layer23">
<form action="http://www.rldigitalphoto.com/sendresults.php" method="post" name="ReorderForm" id="ReorderForm">
<div align="center">
<input type="hidden" name="VTI-GROUP" value="0" />

<strong>Please Note That Orders Are Only Saved For 30 Days After The Date In The Upper Right Corner</strong> </div>
<table border="0" width="100%" id="table1">
<tr>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
</tr>
<tr>
<td align="right"><div align="left" class="style38">* denotes required field </div></td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
</tr>
<tr>
<td align="right">
<p align="left" class="style36">Studio Name/Your Name*</p></td>
<td align="right"><input name="Your_Name" type="text" tabindex="1" onblur="MM_validateForm('Your_Name','','R','Order_Number', '','R');return document.MM_returnValue" size="50" /></td>
<td width="71%">&nbsp; </td>
</tr>
<tr>
<td align="right">
<p align="left" class="style36">Order # from Summary Sheet *</p></td>
<td align="right"><input name="Order_Number" type="text" id="Order_Number" tabindex="2" onblur="MM_validateForm('Order_Number','','R');return document.MM_returnValue" size="50" /></td>
<td width="71%">&nbsp; </td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td align="right"><div align="left" class="style34">(found in the upper left corner under customer name) </div></td>
<td>&nbsp;</td>
</tr>
<tr>
<td align="right"><div align="center"><strong>File # </strong></div></td>
<td align="right"><div align="center"><strong>Print Size </strong></div></td>
<td><div align="center"><strong>Quantity</strong></div></td>
</tr>
<tr>
<td align="right" width="28%"><div align="center">
<input name="File_Number1" type="text" id="File_Number1" tabindex="3" size="40" />
</div></td>
<td align="right" width="28%">
<div align="left">
<input name="Print_Size1" type="text" id="Print_Size1" tabindex="4" size="50" />
</div></td>
<td width="71%">
<div align="left">
<input name="Quantity1" type="text" id="Quantity1" tabindex="5" size="40" />
</div></td>
</tr>
<tr>
<td align="right" width="28%"><input name="File_Number2" type="text" id="File_Number2" tabindex="6" size="40" /></td>
<td align="right" width="28%"><input name="Print_Size2" type="text" id="Print_Size2" tabindex="7" size="50" /></td>
<td width="71%"><input name="Quantity2" type="text" id="Quantity2" tabindex="8" size="40" /></td>
</tr>
<tr>
<td align="right" width="28%"><input name="File_Number3" type="text" id="File_Number3" tabindex="9" size="40" /></td>
<td height="29" align="right" width="28%"><input name="Print_Size3" type="text" id="Print_Size3" tabindex="10" size="50" /></td>
<td height="29" width="71%"><input name="Quantity3" type="text" id="Quantity3" tabindex="11" size="40" /></td>
</tr>
<tr>
<td align="right" width="28%" style="color: #000000"><input name="File_Number4" type="text" id="File_Number4" tabindex="12" size="40" /></td>
<td align="right" width="28%" style="color: #000000"><input name="Print_Size4" type="text" id="Print_Size4" tabindex="13" size="50" /></td>
<td width="71%" style="color: #000000">
<p class="style36">
<input name="Quantity4" type="text" id="Quantity4" tabindex="14" size="40" />
</p></td>
</tr>
<tr>
<td align="right"><input name="File_Number5" type="text" id="File_Number5" tabindex="15" size="40" /></td>
<td align="right"><input name="Print_Size5" type="text" id="Print_Size5" tabindex="16" size="50" /></td>
<td><input name="Quantity5" type="text" id="Quantity5" tabindex="17" size="40" /></td>
</tr>
<tr>
<td align="right" width="28%"><input name="File_Number6" type="text" id="File_Number6" tabindex="18" size="40" /></td>
<td align="right" width="28%"><input name="Print_Size6" type="text" id="Print_Size6" tabindex="19" size="50" /></td>
<td width="71%">
<p class="style36">
<input name="Quantity6" type="text" id="Quantity6" tabindex="20" size="40" />
</p></td>
</tr>
<tr>
<td align="right"><input name="File_Number7" type="text" id="File_Number7" tabindex="21" size="40" /></td>
<td align="right"><input name="Print_Size7" type="text" id="Print_Size7" tabindex="22" size="50" /></td>
<td><input name="Quantity7" type="text" id="Quantity7" tabindex="23" size="40" /></td>
</tr>
<tr>
<td align="right"><input name="File_Number8" type="text" id="File_Number8" tabindex="24" size="40" /></td>
<td align="right"><input name="Print_Size8" type="text" id="Print_Size8" tabindex="25" size="50" /></td>
<td><input name="Quantity8" type="text" id="Quantity8" tabindex="26" size="40" /></td>
</tr>
<tr>
<td align="right"><input name="File_Number9" type="text" id="File_Number9" tabindex="27" size="40" /></td>
<td align="right"><input name="Print_Size9" type="text" id="Print_Size9" tabindex="28" size="50" /></td>
<td><input name="Quantity9" type="text" id="Quantity9" tabindex="29" size="40" /></td>
</tr>
<tr>
<td align="right"><input name="File_Number10" type="text" id="File_Number10" tabindex="30" size="40" /></td>
<td align="right"><input name="Print_Size10" type="text" id="Print_Size10" tabindex="31" size="50" /></td>
<td><input name="Quantity10" type="text" id="Quantity10" tabindex="32" size="40" /></td>
</tr>
<tr>
<td height="21" colspan="3"><p></p></td>
</tr>
<tr>
<td style="color: #000000" colspan="3">
<p align="center" class="style36"><font size="3">Special Notes, Orders, or Comments </font><br />
Fill in below and we will promptly reply.</p>
</td>
</tr>
<tr>
<td colspan="3">
<p align="center">
<textarea name="Questions" cols="75" rows="7" tabindex="33"></textarea></p></td>
</tr>
</table>
<p align="center" class="style36">
<input type="submit" value="Submit" name="B1" tabindex="12" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" value="Reset" name="B2" tabindex="13" />
</p>
</form>
</div></td></tr>
</tr>
<tr>
<td><span class="style16"><a href="aboutus.html">About Us</a></span></td>
</tr>
<tr>
<td><span class="style16"><a href="pricelist.html">R&amp;L Pricelists </a></span></td>
</tr>
<tr>
<td><span class="style16"><a href="becomingacustomer.html">Becoming A Customer </a></span></td>
</tr>
<tr>
<td><span class="style16"><a href="howtoplaceanorder.html">How To Place An Order </a></span></td>
</tr>
<tr>
<td><span class="style16"><a href="whatisworkstreamds.html">What Is WorkStream DS? </a></span></td>
</tr>
<tr>
<td><span class="style16"><a href="workstreamhelpfulhints.html">WorkStream Helpful Hints</a> </span></td>
</tr>
<tr>
<td><span class="style16"><a href="configuration.html">Lab Configurations </a></span></td>
</tr>
<tr>
<td height="22"><a href="fineartmaterials.html" class="style33"></a><a href="fineartmaterials.html" class="style17">Fine Art Materials </a></td>
</tr>
<tr>
<td class="style17"><a href="placeareorder.html" onclick="MM_openBrWindow('http://watchmanjohn.com/fineart.html','','')">Island Gallery</a></td>
</tr>
<tr>
<td class="style17"><a href="placeareorder.html">Place A Reorder </a></td>
</tr>

<tr>
<td><a href="whatsnew.html" class="style17">What's New </a></td>
</tr>
<tr>
<td><a href="mailto:rldigitalphoto@rrohio.com" class="style17">Contact Us </a></td>
</tr>
<tr>
<td><a href="construction.html" class="style17">Links</a></td>
</tr>
</table>
</div>
</div>
<div id="Layer10"><img src="Images/logoNew.jpg" alt="R&amp;L Logo" width="250" height="240" /></div>
<div id="Layer11">
<div align="center"><img src="Images/placeareorder.jpg" alt="How To Place An Order" width="518" height="67" /></div>
</div>
</body>
</html>


______________________________
SENDRESULTS.PHP file
______________________________

<?php
//--------------------------Set these paramaters--------------------------
// Subject of email sent to you.
$subject = 'Customer Reorder from Rldigitalphoto.com';
// Your email address. This is where the form information will be sent.
$emailadd = 'rlreorder@rrohio.com';
// Where to redirect after form is processed.
$url = 'http://www.rldigitalphoto.com';
// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';
// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

Ricky55
08-21-2008, 08:22 PM
why don't you try it and see

AngieMeekie
08-21-2008, 08:32 PM
because I don't have access to their server right now. I'm just updating the pages at home, so I can't publish them.

Is there a way to test it otherwise?

AngieMeekie
08-21-2008, 08:38 PM
hey! I think it's going to work! When I previewed the page this time, it allowed me to "submit" to the www.rldigitalphoto.com/sendresults.php (http://www.rldigitalphoto.com/sendresults.php)... which if I understand it correctly, has the "instructions" for what to do with the form data, right?

Of course, it DIDN'T submit to that because it's not published yet... but theoretically, that's it, right!?

Corrosive
08-22-2008, 06:05 AM
hey! I think it's going to work! When I previewed the page this time, it allowed me to "submit" to the www.rldigitalphoto.com/sendresults.php (http://www.rldigitalphoto.com/sendresults.php)... which if I understand it correctly, has the "instructions" for what to do with the form data, right?

Of course, it DIDN'T submit to that because it's not published yet... but theoretically, that's it, right!?

Yes, that's how it should work.