Old 15-04-2008, 19:15   #1 (permalink)
Drone-7
Registered User
 
Drone-7's Avatar
 
Join Date: Apr 2008
Location: Canada
Posts: 11
Send a message via MSN to Drone-7
Form to Email (PHP or ASP?)

Hi there, I'm doing a website for a company I work for and I need to have data from a form sent to our email address without the usual outlook express opening. I'm thinking maybe ASP or PHP? Here is my code for the form, which is validated with Javascript.

<form name="ff1" method="post">
<table border="0" cellspacing="2" cellpadding="2" width="220">
<tr class="main"><td>First Name&nbsp;</td><td><input name="fname" class="txt" size="15" value=""></td></tr>
<tr class="main"><td>Last Name&nbsp;</td><td><input name="lname" class="txt" size="15"></td></tr>
<tr class="main"><td>Street #&nbsp;</td><td><input name="streetN" class="txt" size="15"></td></tr>
<tr class="main"><td>Street Name&nbsp;</td><td><input name="streetName" class="txt" size="15"></td></tr>
<tr class="main"><td>Postal Code&nbsp;</td><td><input name="PostalCode" class="txt" size="15"></td></tr>
<tr class="main"><td>City&nbsp;</td><td><input name="City" class="txt" size="15"></td></tr>
<tr class="main"><td>Phone Number&nbsp;</td><td><input name="phone" class="txt" size="15"></td></tr>
<tr class="main"><td>Email Address&nbsp;</td><td><input name="email" class="txt" size="15"></td></tr>

<tr class="main"><td colspan="2"><b class="green">Property size</b></td></tr>
<tr class="main"><td align="right">Length</td><td><input name="lenght" class="txt" size="5"> fit</td></tr>
<tr class="main"><td align="right">Width</td><td><input name="width" class="txt" size="5"> fit</td></tr>

<tr><td colspan="2" align="right"><input type="button" value="Calculate Price" style="background-image:url(img/button_bg2.jpg); border:0px; width:90px; height:19px;" onClick="calculatePrice(this.form.lenght.value, this.form.width.value)" class="but"><input type="hidden" name="sub" />&nbsp;&nbsp;</td></tr>
<tr><td colspan="2"><div id="showPrices"></div></td></tr></table></form>
<script type="text/javascript" language="javascript">

function checkField1(){var ref; var msg;//alert();
var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.[a-zA-Z]{2,3})+$/;
ref=true;
msg="Next field is required:\n";
if(Trim(document.ff1.fname.value)==''){msg+=" - Name\n"; ref=false;}
if(Trim(document.ff1.lname.value)==''){msg+=" - Last Name\n"; ref=false;}

if(Trim(document.ff1.streetN.value)=='') {msg+=" - Street #\n"; ref=false;}
if(Trim(document.ff1.streetName.value)=='') {msg+=" - Street Name\n"; ref=false;}
if(Trim(document.ff1.PostalCode.value)=='') {msg+=" - Postal Code\n"; ref=false;}
if(Trim(document.ff1.City.value)=='') {msg+=" - City\n"; ref=false;}


//if(Trim(document.ff1.address.value)==''){msg+=" - Address\n"; ref=false;}
//if(Trim(document.ff1.stateCode.value)==''){msg+=" - Province\n"; ref=false;}
//if(Trim(document.ff1.countryCode.value)==''){msg+= " - Country\n"; ref=false;}
//if(Trim(document.ff1.zip.value)==''){msg+=" - Postal Code\n"; ref=false;}
if(Trim(document.ff1.phone.value)==''){msg+=" - Phone\n"; ref=false;}
if(!re.test(document.ff1.email.value)){msg+=" - Email is wrong\n"; ref=false;}
if(document.ff1.priceR[0].checked==false && document.ff1.priceR[1].checked==false && document.ff1.priceR[2].checked==false)
{msg+=" - Select package\n"; ref=false;}
//if(Trim(document.ff1.email.value)==''){msg+=" - Username\n"; ref=false;}
if(ref){
document.ff1.sub.value='Update';
document.ff1.action='checkout.html';//https://
document.ff1.submit();
}
else {alert(msg);return false;} }
</script>

We're gathering information on square footage for measuring property sizes and following up with an estimate, but my main concern is generally getting the info from the form sent to our email address so we can follow up.

Any help would be greatfully appreciated.
  Reply With Quote
Old 15-04-2008, 22:49   #2 (permalink)
Heka1
Senior Member
 
Join Date: Jul 2007
Posts: 179
Either one works, I guess you don't have any experience programming so I would suggest picking a php email() tutorial that fits your learning style. you can also get some great help by looking on PHP: Hypertext Preprocessor and type in email() in the function search bar, it will give you some working examples.
__________________
XHTML, CSS, PHP, Flash Web Designer
www.Heka1.com
www.DrunkMobile.com/m
  Reply With Quote
Old 15-04-2008, 23:46   #3 (permalink)
timbe
del.icio.us/timbe
 
Join Date: Dec 2006
Posts: 26
Send a message via AIM to timbe Send a message via MSN to timbe Send a message via Yahoo to timbe
Make sure you whatever you choose uses server side validation, javascript validation is extremely easy to bypass and you don't want to open yourself up to cross site scripting
  Reply With Quote
Old 16-04-2008, 08:22   #4 (permalink)
Aibrean
Art Director
 
Aibrean's Avatar
 
Join Date: Jan 2004
Location: Dayton, OH
Posts: 76
Send a message via AIM to Aibrean
Jack's Scripts

That's probably the best one to put up (Jack's Formmail). It works with any hosting and is very self-explanatory.
  Reply With Quote
Old 16-04-2008, 14:53   #5 (permalink)
Drone-7
Registered User
 
Drone-7's Avatar
 
Join Date: Apr 2008
Location: Canada
Posts: 11
Send a message via MSN to Drone-7
Hi, thanks for the help. I've decided to use ASP for the form. I created the form page, but whenever I submit the info the page directs itself to the form_ac.asp page (Which is my code page). I threw the code into remotesite/aspnet_client folder. I did some ASP in school but my skills are quite rusty. So in a nutshell, Im tryin to get info from the form sent via email without it opening any email client like Outlook etc.
  Reply With Quote
Old 16-04-2008, 19:17   #6 (permalink)
Drone-7
Registered User
 
Drone-7's Avatar
 
Join Date: Apr 2008
Location: Canada
Posts: 11
Send a message via MSN to Drone-7
PHP and Javascript now

Okay so I got my PHP working on Godaddy, but I'm using a company server for the site I'm working on, so what information would I need about our server in order to enable PHP? I'm simply making revisions on my notebook and uploading via Filezilla. But the real problem lies with the actions of the form Im working on.

It asks for standard information like name, address, etc. And it asks for dimensions of their lawns, and the javascript calculates their dimensions and gives them an estimate for our services, but when they enter their info, I want that info to be sent to us through a form-to-email PHP funtion. How can I go about this since I cant change the POST function on the forms' script. Here's my code for the Javascript form:

<form name="ff1" method="post">
<table border="0" cellspacing="2" cellpadding="2" width="220">
<tr class="main"><td>First Name&nbsp;</td><td><input name="fname" class="txt" size="15" value=""></td></tr>
<tr class="main"><td>Last Name&nbsp;</td><td><input name="lname" class="txt" size="15"></td></tr>
<tr class="main"><td>Street #&nbsp;</td><td><input name="streetN" class="txt" size="15"></td></tr>
<tr class="main"><td>Street Name&nbsp;</td><td><input name="streetName" class="txt" size="15"></td></tr>
<tr class="main"><td>Postal Code&nbsp;</td><td><input name="PostalCode" class="txt" size="15"></td></tr>
<tr class="main"><td>City&nbsp;</td><td><input name="City" class="txt" size="15"></td></tr>
<tr class="main"><td>Phone Number&nbsp;</td><td><input name="phone" class="txt" size="15"></td></tr>
<tr class="main"><td>Email Address&nbsp;</td><td><input name="email" class="txt" size="15"></td></tr>

<tr class="main"><td colspan="2"><b class="green">Property size</b></td></tr>
<tr class="main"><td align="right">Length</td><td><input name="lenght" class="txt" size="5"> fit</td></tr>
<tr class="main"><td align="right">Width</td><td><input name="width" class="txt" size="5"> fit</td></tr>

<tr><td colspan="2" align="right"><input type="button" value="Calculate Price" style="background-image:url(img/button_bg2.jpg); border:0px; width:90px; height:19px;" onClick="calculatePrice(this.form.lenght.value, this.form.width.value)" class="but"><input type="hidden" name="sub" />&nbsp;&nbsp;</td></tr>
<tr><td colspan="2"><div id="showPrices"></div></td></tr></table></form>

<script type="text/javascript" language="javascript">

function checkField1(){var ref; var msg;//alert();
var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.[a-zA-Z]{2,3})+$/;
ref=true;
msg="Next field is required:\n";
if(Trim(document.ff1.fname.value)==''){msg+=" - Name\n"; ref=false;}
if(Trim(document.ff1.lname.value)==''){msg+=" - Last Name\n"; ref=false;}

if(Trim(document.ff1.streetN.value)=='') {msg+=" - Street #\n"; ref=false;}
if(Trim(document.ff1.streetName.value)=='') {msg+=" - Street Name\n"; ref=false;}
if(Trim(document.ff1.PostalCode.value)=='') {msg+=" - Postal Code\n"; ref=false;}
if(Trim(document.ff1.City.value)=='') {msg+=" - City\n"; ref=false;}


//if(Trim(document.ff1.address.value)==''){msg+=" - Address\n"; ref=false;}
//if(Trim(document.ff1.stateCode.value)==''){msg+=" - Province\n"; ref=false;}
//if(Trim(document.ff1.countryCode.value)==''){msg+= " - Country\n"; ref=false;}
//if(Trim(document.ff1.zip.value)==''){msg+=" - Postal Code\n"; ref=false;}
if(Trim(document.ff1.phone.value)==''){msg+=" - Phone\n"; ref=false;}
if(!re.test(document.ff1.email.value)){msg+=" - Email is wrong\n"; ref=false;}
if(document.ff1.priceR[0].checked==false && document.ff1.priceR[1].checked==false && document.ff1.priceR[2].checked==false)
{msg+=" - Select package\n"; ref=false;}
//if(Trim(document.ff1.email.value)==''){msg+=" - Username\n"; ref=false;}
if(ref){
document.ff1.sub.value='Update';
document.ff1.action='checkout.html';//https://
document.ff1.submit();
}
else {alert(msg);return false;} }
</script>


Now I want the info calculated to be sent to us via email using PHP without calling an email client like Outlook.

Any help would be greatfully appreciated.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8