PDA

View Full Version : sendresults.php


gregersp10
12-13-2010, 03:03 PM
i have recently created a website which needs an order request from i have made a form to do this and have used sendresults.php tp send the details. However it is not sending all the inputted data. the data it is not sending is in a list field where more than one item can be selected. is there any way i can modify the code or find an alternative code in which all the data that the user puts in is emailed to me.

Corrosive
12-13-2010, 03:19 PM
is there any way i can modify the code or find an alternative code in which all the data that the user puts in is emailed to me.

Yes there is.

gregersp10
12-13-2010, 03:30 PM
thanks for that any help?

Corrosive
12-13-2010, 03:33 PM
thanks for that any help?

Not without any code ;)

gregersp10
12-13-2010, 03:36 PM
thanks for that any help?

gregersp10
12-13-2010, 03:38 PM
<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Order Request';

// Your email address. This is where the form information will be sent.
$emailadd = 'greg@parrott.co.uk';

// Where to redirect after form is processed.
$url = 'http://www.absalomandtribe.co.uk/index.html';

// 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 >= 100)
{echo "Name of form element $key cannot be longer than 100 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.'">';
?>





thats the php code

the html code is as follows:

<!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>
<TITLE>Order Form</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function mailMe(form){
Subject=document.orderform.inputbox1.value
CC= document.orderform.inputbox2.value
BCC= document.orderform.inputbox3.value
location = "/javaworld/cgi-bin/jw-mailto.cgi?greg@parrott.co.uk?subject="+Subject+"&Bcc="+
BCC+"&cc="+CC
document.orderform.submit();
}
</SCRIPT>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Absalom &amp; Tribw Company Information</title>
<link href="/CSSFiles/testing.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-image: url(Images/Backgroundpp.jpg);
background-repeat: repeat;
}
body,td,th {
font-family: Verdana, Geneva, sans-serif;
color: #000;
}
-->
body,td,th {
color: #000;
font-family: Verdana, Geneva, sans-serif;
}
body {
background-color: #FFF;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-image: url(Images/Backgroundpp.jpg);
background-repeat: repeat;
}

-->
/
.oneColElsCtrHdr #footer {
padding: 0 10px; /* this padding matches the left alignment of the elements in the divs that appear above it. */
background:#DDDDDD;
}
.oneColElsCtrHdr #footer p {
margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */
padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */
}
-->
</style>
<link href="CSSFiles/testing.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
function MM_validateForm() { //v4.0
if (document.getElementById){
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=document.getElementById(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>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>

<body class="oneColElsCtrHdr">

<div id="container">
<div id="header">
<h1 align="justify"><img src="Images/bannert with text.png" width="100%" height="200" alt="" /></h1>
<ul id="MenuBar1" class="MenuBarHorizontal">
<li><a class="MenuBarItemSubmenu" href="#">Home</a>
<ul>
<li><a href="index.html">Background Info &amp; History</a></li>
<li><a href="CompanyInfo.html">Company Information</a></li>
</ul>
</li>
<li><a href="#" class="MenuBarItemSubmenu">Products</a>
<ul>
<li><a href="beef.html">Beef</a></li>
<li><a href="lamb.html">Lamb</a></li>
<li><a href="pork.html">Pork</a></li>
<li><a href="veal.html">Veal</a></li>
<li><a href="boxed.html">Boxed</a></li>
</ul>
</li>
<li><a href="Contact.html">Contact Us</a></li>
</ul>
<p align="justify">&nbsp;</p>
<!-- end #header --></div>
<form id="Order Form" name="Order Form" method="post" action="sendresults.php">
Please Submit Request for orders for forthcoming week
<table width="547" border="0" align="center">
<tr>
<td width="225"><label>Company Name: </label></td>
<td width="312"><input name="nameField" type="text" id="nameField" accesskey="n" tabindex="1" maxlength="50" /></td>
</tr>
<tr>
<td>Email Address:</td>
<td><input name="emailField" type="text" id="emailField" accesskey="e" tabindex="2" maxlength="50" /></td>
</tr>
<tr>
<td><label>Telephone Number:</label></td>
<td><input name="PhoneField" type="text" id="PhoneField" accesskey="t" tabindex="3" maxlength="12" /></td>
</tr>
<tr>
<td><label for="Beef">Beef Products: </label></td>
<td><select name="beefproductList" size="10" multiple="MULTIPLE" id="beefproductList" accesskey="p" tabindex="4">
<option>Chuck And Blade</option>
<option>Ribeye</option>
<option>Silverside</option>
<option>Thick Flank</option>
<option>Topside</option>
<option>Knuckle</option>
<option>Fillet</option>
<option>Shin</option>
<option>Forerib</option>
<option>Striploin</option>
</select></td>
</tr>
<tr>
<td><label for="Lamb">Lamb Products </label></td>
<td><select name="lambproductsLis" size="10" multiple="MULTIPLE" id="lambproductsLis" tabindex="5">
<option>Shoulder</option>
<option>Scrag End</option>
<option>Chump</option>
<option>Best End</option>
<option>Leg</option>
<option>Breast</option>
<option>Loin</option>
</select></td>
</tr>
<tr>
<td>Pork Products: </td>
<td><select name="porkproductsList" size="10" multiple="MULTIPLE" id="porkproductsList" tabindex="6">
<option>Leg</option>
<option>Ribs</option>
<option>Hock</option>
<option>Belly</option>
<option>Hand</option>
<option>Trotter</option>
<option>Blade</option>
<option>Loin</option>
</select></td>
</tr>
<tr>
<td>Veal Products:</td>
<td><select name="vealproductList" size="10" multiple="MULTIPLE" id="vealproductList" tabindex="7">
<option>Haunche</option>
<option>Chump</option>
<option>Chine</option>
<option>Best End</option>
<option>Rumps</option>
<option>Liver</option>
</select></td>
</tr>
<tr>
<td></td>
<td>&nbsp;</td>
</tr>
<tr>
<td><label>Additional Comments: </label></td>
<td><textarea name="commentsField" id="commentsField" cols="45" rows="5" tabindex="8"></textarea></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>
<input name="Recipient" type="hidden" id="Recipient" value="greg@parrott.co.uk" />
</p>
<p>&nbsp;</p>
<p>
<label>
<input name="Submit" type="submit" id="button" onclick="MM_validateForm('emailField','','RisEmail','PhoneF ield','','RisNum');return document.MM_returnValue" value="Send Order" />
</label>
<label>
<input type="reset" name="button2" id="button2" value="Reset" />
</label>
</p>
<p>&nbsp;</p>
</form>
<p>&nbsp;</p>
<div align="center">
<table width="247" border="0">
<tr>
<td width="237"><pre> PTP Ltd 2010</pre></td>
</tr>
</table>
</div>

<!-- end #container --></div>
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
//-->
</script>
</body>

</html>

edbr
12-14-2010, 01:36 AM
ste the form field as an array ie
<select name="beefproductList[]" size="10" multiple="MULTIPLE" id="beefproductList" accesskey="p" tabindex="4">