FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


asp.net email form





socceraggie
I've created an ASP.net email form for my website but wanted to make sure this was supported by Frihost. Also if anyone has some good sample code or suggestions on a better way to create this tool, please let me know. The goal is for a client to fill out the form and the submit button to send me an e-mail with the entered information.

Here is the ASP file:

Code:
<%
' declare variables
Dim strOwnerNameFirst
Dim strOwnerNameLast
Dim strPetName
Dim strFood
Dim strType
Dim strSize
Dim strQuantity
Dim strPhone
Dim strBody


'First we'll read in the values entered
strOwnerNameFirst = Request.Form("OwnersNameFirst")
strOwnerNameLast = Request.Form("OwnersNameLast")
strPetName = Request.Form("petName")
strFood = Request.Form("food")
strType = Request.Form("CannedorDry")
strSize = Request.Form("size")
strQuantity = Request.Form("quantity")
strPhone = Request.Form("phone")

' validation
dim validationOK
validationOK=true
If (trim(strOwnerNameFirst)="") Then validationOK=false
If (trim(strOwnerNameLast)="") Then validationOK=false
If (trim(strPetName)="") Then validationOK=false
If (trim(strFood)="") Then validationOK=false
If (trim(strType)="") Then validationOK=false
If (trim(strSize)="") Then validationOK=false
If (trim(strQuantity)="") Then validationOK=false
If (trim(strPhone)="") Then validationOK=false
If (validationOK=false) Then Response.Redirect("Food_Ordering_Error.html")

' create email body with entered responses
strBody = "Owner Name: " & strOwnerNameFirst & " " & strOwnerNameLast & vbCrLf
strBody = strBody & "Pet Name: " & strPetName & vbCrLf
strBody = strBody & "Food: " & strFood & vbCrLf
strBody = strBody & "Canned or Dry: " & strType & vbCrLf
strBody = strBody & "Size: " & strSize & vbCrLf
strBody = strBody & "Quantity: " & strQuantity & vbCrLf
strBody = strBody & "Phone Number: " & strPhone & vbCrLf
strBody = strBody & vbCrLf

' send email
Dim mail
Set mail = Server.CreateObject("CDONTS.NewMail")
mail.To = "foodorders@mydomainname.com"
mail.From = "foodorders@mydomainname.com.com"
mail.Subject = "Food Order from " & strOwnerNameFirst & " " & strOwnerNameLast
mail.Body = strBody
mail.send

' redirect to success page
Response.Redirect("Food_Ordering_Thank_you.html"

' End page logic
%>



Thank you for any assistance!
rockacola
I believe Frihost does not support ASP nor ASP.NET Embarassed
rvec
I added quote tags to the post.

And no we do not support asp. You can use php to make the same thing though, just make sure you get a good script and not allow spammer to abuse it.
socceraggie
Thank you for the help. I've modified my file into a PHP file. Here is the new PHP file I've created:

Quote:
<?php

$strOwnerNameFirst = $_REQUEST['OwnersNameFirst'];
$strOwnerNameLast = $_REQUEST['OwnersNameLast'];
$strPetName = $_REQUEST['petName'];
$strFood = $_REQUEST['food'];
$strType = $_REQUEST['CannedorDry'];
$strSize = $_REQUEST['size'];
$strQuantity = $_REQUEST['quantity'];
$strPhone = $_REQUEST[phone'];

$body = "Food Order\n Owner's name: $strOwnerNameFirst $strOwnerNameLast\n Pet's Name: $strPetName\n Food: $strFood\n Canned or Dry: $strType\n Size: $strSize\n Quantity: $strQuantity\n Phone Number: $strPhone\n"

if (!isset($_REQUEST['OwnersNamefirst'])) {
header( "Location: http://www.mydomain.com/Food_Ordering.html");
}
elseif (empty($strOwnerNameFirst) || empty($strOwnerNameLast) || empty($strPetName) || empty($strFood) || empty($strType) || empty($strSize) || empty($strQuantity) || empty($strPhone)) {
header("Location: http://www.mydomain.com/Food_Ordering_Error.html");
}
else {
mail("foodorders@mydomain.com", "Food Order", $body, "From: $strOwnerNameFirst $strOwnerNameLast");
header( "Location: http://www.mydomain.com/Food_Ordering_Thank_you.html" );
}

?>


Unfortunately this still does not work. On a PC it tries to download a .zip file of the PHP file above. On a MAC i get the following:

Quote:
PK;:^2 ''mimetypeapplication/vnd.oasis.opendocument.textPK;:R> content.xmlX]o6}߯ഢqɌ6mT%OI..0`,to/e)t{s<>3t˔RLA @LPs1fgxX& ,%]LJa7BGt,$\GLGF`Ҋ*mV#7 3mώԎY*H_;U bx'O 50^./ӚW,TX1,cLA+n ͐"aʻ4Đ۹DηDyφ#;;91閞V>.gA徾*UNd7u P^P. QRqTNSѺ2h7[zz⚬ 8)=r PJki4+ÄPƌfz:.gQyMPg<[KtY^da@NCgv>[ rSEi%l|wK +vLTTa U3vJd kPq([b,A?(>z9`-r ȱ 6͘ǰF×\TcՏ ôxU ~ӱ{}5ml<3o{hS2|zL]Z+m=ӫ{Nko9nd;Y} %3)㶕"; N 'DKZdޅ%;x pjsVTv8 6<=[/[3Q 7{/BhY%;VVY_(;BGh%Ѓ_*Z ܹ\wC@>)kL7r֡viʈ-w$EOv{FVDd7$WD UvY9X¬z>Fa:tPHt TM@ [mM>UJ_VNx `JQ='T2I?_R">]䢬>z{:pob/PK;:ID styles.xmlVn0+ eZI $zjNM?&)%Hr]RS~$z Yp9TQ+%zDÀ˦%~OB2s`m-Z]aqc>KZ@ yCkasrТV}$<j'Nnijay玫bEMJ HԚ:ydK*tNHuq $3 ى0p5* 8#B ̒l[ GؘRaKCU{,oı# Y<Gzy\[SWݹ'yLΤbFc&  f鄉S8MC}K4e85MVlk?zTOe")5WhIT*Y Z1N[r!؄jǡx*S$1N)<tʥuY4 ʮhA+b0{Xo `d+ћ & K(EEƩ9Fb8:uP Wy  {~ܽ!} 3.I )H7FR~@n7d:ɽ<%e֐ (#q!H|MHɿ *]( )e q*DS ϷsZ!Q\!Ob%Wg\t% PK;:kEmeta.xml1O0w~E佾f , f˹χ8j}߽yO ёoXKV :5{`}treKvЧ݀߫>u԰)xI&(0d%yMl{?(yS B@nhk/8>S qqP 6vIP {.F veYf17 ET,ݡ`H-D-xWRpPK;:0.eaMETA-INF/manifest.xml j0<zv+v q tNds߾rMJw'Sh/CPya]4-딷-FˁO/un[ DTm%w`\qC,` *(0J2$ zГ劝 u0],ƪ P}VA.~'sw;:>  %I"M7MOoܒiroO_PK;:^2 ''mimetypePK;:R> Mcontent.xmlPK;:ID styles.xmlPK;:kEZmeta.xmlPK;:0.eadMETA-INF/manifest.xmlPK 


I'm not sure what I'm doing wrong and would appreciate any comments or links to good tutorial sites.

Thank you!
Diablosblizz
Did you name it file.php? Of course changing file to whatever you want.
socceraggie
That is correct. The file that the submit button calls is appropriately labeled: file.php

I originally created the site and the PHP file on a macbook and thought that might have something to do with it, but I re-created the PHP file on a windows machine and uploaded the file.

Another weird thing that it is doing is that if I just provide the file file name in the HTML form it tries to look for the file with an extra "/" so it looks like this: www.mydomain.com//file.php

Thanks.
Diablosblizz
Could you perhaps post the URL here? I suppose you can name it differently then change it when you've fixed it.

EDIT: Looking at your code I've found two mistakes.

Code:
<?php

$strOwnerNameFirst = $_REQUEST['OwnersNameFirst'];
$strOwnerNameLast = $_REQUEST['OwnersNameLast'];
$strPetName = $_REQUEST['petName'];
$strFood = $_REQUEST['food'];
$strType = $_REQUEST['CannedorDry'];
$strSize = $_REQUEST['size'];
$strQuantity = $_REQUEST['quantity'];
$strPhone = $_REQUEST['phone'];

$body = "Food Order\n Owner's name: $strOwnerNameFirst $strOwnerNameLast\n Pet's Name: $strPetName\n Food: $strFood\n Canned or Dry: $strType\n Size: $strSize\n Quantity: $strQuantity\n Phone Number: $strPhone\n";

if (!isset($_REQUEST['OwnersNamefirst'])) {
header( "Location: http://www.mydomain.com/Food_Ordering.html");
}
else if (empty($strOwnerNameFirst) || empty($strOwnerNameLast) || empty($strPetName) || empty($strFood) || empty($strType) || empty($strSize) || empty($strQuantity) || empty($strPhone)) {
header("Location: http://www.mydomain.com/Food_Ordering_Error.html");
}
else {
mail("foodorders@mydomain.com", "Food Order", $body, "From: $strOwnerNameFirst $strOwnerNameLast");
header( "Location: http://www.mydomain.com/Food_Ordering_Thank_you.html" );
}

?>


You were missing:

A single quote (') before phone on variable $strPhone
A semi colon at end of variable $body.

It works sucesfully for me on my Frihost account, it redirects me to mydomain.com without any data. It should work now for you.

Let us know if it does.
socceraggie
http://www.mandalayanimalhospital.com/food_ordering.html
Diablosblizz
URL was not found (it also was a .html) and check the post above yours. I updated it with "working" code. It works for me, not sure about you.
socceraggie
I also found those typos in the code and already corrected them. I'm not sure why, but the web address is case sensitive. Try this one:

http://www.mandalayanimalhospital.com/Food_Ordering.html
Diablosblizz
Hmm, are you using the Directadmin page to edit / create this file? If so, I don't know what's going on here. If not, try it with Directadmin. Perhaps your text editing program is saving in a different encoding, as this is what it looks like.
socceraggie
I am kinda new to frihost so I hadn't created any files using the directAdmin. I recreated the file using this and that fixed the problem but now each time i click on the submit button, it just refreshes the page.

Any new thoughts? I've gone through the code again and it seems correct.
socceraggie
Nevermind! The issue I was having dealt with the statement:


Code:
if (!isset($_REQUEST['OwnersNamefirst'])) {
   header( "Location: http://www.mandalayanimalhospital.com/Food_Ordering.html");
}


Not sure what this statement was suppose to do but it was causing the form to not work properly. Once removed, the form appears to be working correctly.

Thank you for all of your help!!![/code]
rvec
there are some security problems with that script. It'd be really easy for a spammer to use that script to send spam to anyone.
http://www.phpf1.com/product/contact-form-script.html
Try that script instead, it's not perfect but there's at least some security there.
socceraggie
Could you please explain what the security concerns with this script are? From what I have read online, the security risks arise if you have the user enter an e-mail address for a response to be sent to. In the case of my script, I'm having the user complete a form and an e-mail be sent to a hard coded address that is hidden from the user.

If you could please elaborate on the issues with this script.

Thank you!
rvec
Quote:
Code:
From: $strOwnerNameFirst $strOwnerNameLast

What if I use the name "rvec \n To:mail@me.com \n To: more@mail.com"
Related topics
I'd love ASP.NET support
Using TinyMCE with ASP.NET
Flash & ASP.NET
ASP.NET - Is this possible with frihost?
Web hosting com Asp.net
neep help making email form that accepts html tags
Suggest me a ASP.NET Spidering Book
Running ASP && ASP.NET -> APACHE
Asp.net 2.0 and ajax technology
asp.net 2.0
email form handling on a windows 2000 server help.
ASP.NET 2.0 supported?
Using Windows Media Player with Asp.NET
ASP.NET 1.0 email form
Reply to topic    Frihost Forum Index -> Support and Web Hosting -> Web Hosting Support

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.