AmritSingh
07-01-2010, 02:36 AM
Hey guys, Im trying create a form in which once submitted it will send it to my email.
Im looking at the old website which was designed for me ages ago and cant get hold of the admin of my website since he left. So they recommended me extracting the website since I knew some stuff to edit it.
Basically i have a form which takes my booking reservations. One thing i cannot obtain is the script the site uses for the server to send an email to my email showing the values!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Restaurant Booking Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {
font-size: 18px;
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #E9415A;
}
.style2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-style: normal;
font-weight: normal;
color: #333333;
}
.style3 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: normal;
color: #333333;
}
.style4 {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #FF0000;
font-size: 12px;
}
-->
</style>
<script language="JavaScript">
function validate()
{
if(document.inquiry.Name.value=="")
{
alert("Please Enter FullName");
document.inquiry.Name.focus();
return false;
}
if(document.inquiry.Email.value=="")
{
alert("Please Enter Email-Address");
document.inquiry.Email.focus();
return false;
}
if(document.inquiry.Telephone_Number.value=="")
{
alert("Please Enter Telephone_Number");
document.inquiry.Telephone_Number.focus();
return false;
}
if(isNaN(document.inquiry.Telephone_Number.value))
{
alert("Please Enter Telephone_Number in Digits");
document.inquiry.Telephone_Number.focus();
return false;
}
if(document.inquiry.date_day.options[document.inquiry.date_day.selectedIndex].value=="DD")
{
alert("Please enter ReservationDay");
return false;
}
if(document.inquiry.date_month.options[document.inquiry.date_month.selectedIndex].value=="MM")
{
alert("Please enter ReservationMonth");
return false;
}
if(document.inquiry.date_year.options[document.inquiry.date_year.selectedIndex].value=="YYYY")
{
alert("Please enter ReservationYear");
return false;
}
if(document.inquiry.Time_of_reservation.value=="")
{
alert("Please Enter Time_of_reservation");
document.inquiry.Time_of_reservation.focus();
return false;
}
return checkmail();
return true;
}
function checkmail()
{
var mi,i;
mi=document.inquiry.Email.value;
if(mi > "")
{
var temp=new Array();
temp=mi.split('@');
if(temp.length > 2)
{
alert("Invalid Email Address");
return false;
}
if(mi.indexOf("@")==-1 || mi.indexOf(".") == -1)
{
alert("Invalid Email Id");
return false;
}
if((mi.indexOf("@")==mi.indexOf(".")-1))
{
alert("Invalid Email Id");
return false;
}
var str = "!#$%^&*()-+/\{}';:`~";
for(i=0;i<str.length;i++)
{
if(mi.indexOf(str.charAt(i)) != -1)
{
alert("Invalid Email Address");
return false;
}
}
}
}
</script>
</head>
<LINK href="form.css" type=text/css rel=stylesheet>
<body topmargin="0" leftmargin="0" bgcolor="#F3F3EC">
<form action="form.asp?flag=1" method="post" name="inquiry">
<table border="0" width="400" cellpadding="0" cellspacing="0" align="center">
<tr>
<td><div align="center"><img src="masala-logo.png" width="110" height="145"></div></td>
<td align="right" valign="bottom" class="smalltext1">
<div align="right"><br>
<br>
<br>
<br>
<span class="style1">Restaurant Booking Form </span></div></td>
</tr>
</table>
<table border="0" width="400" cellpadding="2" cellspacing="0" align="center">
<tr>
<td width="149" class="maintext">
<div align="left">
<label for="Name" class="style3">Full Name:</label>
<span class="style4">*</span> </div> </td>
<td height="25" colspan="2" align="left" valign="middle" class="maintext">
<input name="Name" type="text" class="style2" id="Name" size="40" /></td>
</tr>
<tr>
<td class="maintext">
<div align="left"><label for="Email" class="style3">Email
address:</label>
<span class="style4">*</span></div> </td>
<td height="25" colspan="2" align="left" valign="middle" class="maintext">
<input name="Email" type="text" class="style2" id="Email" size="40" /> </td>
</tr>
<tr>
<td class="maintext">
<div align="left">
<label for="Membership_Number" class="style3">Membership Number:</label>
</div> </td>
<td height="25" colspan="2" align="left" valign="middle" class="maintext" >
<input name="Membership_Number" type="text" class="style2" id="Membership_Number" size="40" /> </td>
</tr>
<tr>
<td class="maintext">
<div align="left">
<label for="Telephone_Number" class="style3">Telephone Number:</label>
<span class="style4">*</span></div> </td>
<td height="25" colspan="2" align="left" valign="middle" class="maintext" >
<input name="Telephone_Number" type="text" class="style2" id="Telephone_Number" size="40" /> </td>
</tr>
<tr>
<td class="maintext">
<div align="left">
<label for="Date_of_reservation" class="style3">Date
of Reservation<br>
(dd/mm/yyyy):</label>
<span class="style4">*</span></div> </td>
<td height="25" colspan="2" align="left" valign="middle" class="maintext" >
<select name="date_day" size=1 id="date_day" class="style2">
<option value="DD" selected>DD</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="date_month" size=1 id="date_month" class="style2">
<option value="MM" selected>MON</option>
<option value="01">Jan </option>
<option value="02">Feb </option>
<option value="03">Mar </option>
<option value="04">Apr </option>
<option value="05">May </option>
<option value="06">Jun </option>
<option value="07">Jul </option>
<option value="08">Aug </option>
<option value="09">Sep </option>
<option value="10">Oct </option>
<option value="11">Nov </option>
<option value="12">Dec</option>
</select>
<select name="date_year" size=1 id="date_year" class="style2">
<option value="YYYY" selected>YYYY</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
</select> </td>
</tr>
<tr>
<td class="maintext">
<div align="left"><label for="Time_of_reservation" class="style3">Time
of Reservation:</label>
<span class="style4">*</span></div> </td>
<td height="25" colspan="2" align="left" valign="middle" class="maintext" >
<input name="Time_of_reservation" type="text" class="style2" id="Time_of_reservation" size="12" />
<select name="meridian" size=1 class="style2">
<option value="AM">AM</option>
<option value="PM">PM</option>
</select>
</td>
</tr>
<tr>
<td class="maintext">
<div align="left"><label for="Number_of_people" class="style3">Number
of People:</label>
<span class="style4">*</span></div> </td>
<td height="25" colspan="2" align="left" valign="middle" class="maintext">
<select name="Number_of_people" class="style2" id="Number_of_people">
<option selected="selected">1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
</select> </td>
</tr>
<tr>
<td valign="top" class="maintext"><label for="further_information" class="style3">Futher Information:</label> </td>
<td height="85" colspan="2" align="left" valign="middle" class="maintext"><textarea name="further_information" cols="40" rows="6" class="style2" id="further_information"></textarea> </td>
</tr>
<tr>
<td rowspan="3" class="maintext"> </td>
<td colspan="2" align="center" valign="middle" class="maintext"><p> </p></td>
</tr>
<tr>
<td width="113" align="center" valign="middle" class="maintext"><input name="submit" type="submit" onClick="return validate();return true;" value="Send Form"/></td>
<td width="126" align="center" valign="middle" class="maintext"><input name="reset" type="reset" value="Reset Form" /></td>
</tr>
<tr>
<td colspan="2" align="center" valign="middle" class="maintext"> </td>
</tr>
</table>
</form>
</body>
</html>
This is the code of my form.
Notice though the <form action="form.asp?flag=1" method="post" name="inquiry">.
Im confused on what that flag=1 is for?
When the submit button is pressed the SAME page loads up (without the values they entered) but now a "Enquiry sent successfully" text shows up.
Im terribly confused on what code they used to do this and very much appriciate if someone could assist me?
Iv brought about using this code for when its updated since i couldnt figure out how to obtain the code they use to send the value by email:
<%
' declare variables
Dim EmailFrom
Dim EmailTo
Dim Subject
Dim Name
Dim Email
Dim Membership_Number
Dim Telephone_Number
Dim Date_of_reservation
Dim Time_of_reservation
Dim Number_of_people
Dim further_information
' get posted data into variables
EmailFrom = Trim(Request.Form("info@masala910.co.uk"))
EmailTo = "info@masala910.co.uk"
Subject = "Restaurant Booking"
Name = Trim(Request.Form("Name"))
Email = Trim(Request.Form("Email"))
Membership_Number = Trim(Request.Form("Membership_Number"))
Telephone_Number = Trim(Request.Form("Telephone_Number"))
Date_of_reservation = Trim(Request.Form("Date_of_reservation"))
Time_of_reservation = Trim(Request.Form("Time_of_reservation"))
Number_of_people = Trim(Request.Form("Number_of_people"))
further_information = Trim(Request.Form("further_information"))
' validation
Dim validationOK
validationOK=true
If (Trim(EmailFrom)="") Then validationOK=false
If (Trim(Name)="") Then validationOK=false
If (Trim(Email)="") Then validationOK=false
If (Trim(Membership_Number)="") Then validationOK=false
If (Trim(Telephone_Number)="") Then validationOK=false
If (Trim(Date_of_reservation)="") Then validationOK=false
If (Trim(Time_of_reservation)="") Then validationOK=false
If (Trim(Number_of_people)="") Then validationOK=false
If (Trim(further_information)="") Then validationOK=false
If (validationOK=false) Then Response.Redirect("error.htm?" & EmailFrom)
' prepare email body text
Dim Body
Body = Body & "A reservation has been made by" & VbCrLf
Body = Body & "Name: " & Name & VbCrLf
Body = Body & "Email: " & Email & VbCrLf
Body = Body & "Telephone Number: " & Telephone_Number & VbCrLf
Body = Body & "Membership Number: " & Membership_Number & VbCrLf
Body = Body & "Date of reservation: " & Date_of_reservation & VbCrLf
Body = Body & "Time of reservation: " & Time_of_reservation & VbCrLf
Body = Body & "Number of people: " & Number_of_people & VbCrLf
Body = Body & "Further Information: " & further_information & VbCrLf
' send email
Dim mail
Set mail = Server.CreateObject("CDONTS.NewMail")
mail.To = EmailTo
mail.From = EmailFrom
mail.Subject = Subject
mail.Body = Body
mail.Send
' redirect to success page
Response.Redirect("needtoedit.htm" & EmailFrom)
%>
If it total bull then please do say:D
Thanks for the help!!
Amrit
Im looking at the old website which was designed for me ages ago and cant get hold of the admin of my website since he left. So they recommended me extracting the website since I knew some stuff to edit it.
Basically i have a form which takes my booking reservations. One thing i cannot obtain is the script the site uses for the server to send an email to my email showing the values!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Restaurant Booking Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {
font-size: 18px;
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #E9415A;
}
.style2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-style: normal;
font-weight: normal;
color: #333333;
}
.style3 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: normal;
color: #333333;
}
.style4 {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #FF0000;
font-size: 12px;
}
-->
</style>
<script language="JavaScript">
function validate()
{
if(document.inquiry.Name.value=="")
{
alert("Please Enter FullName");
document.inquiry.Name.focus();
return false;
}
if(document.inquiry.Email.value=="")
{
alert("Please Enter Email-Address");
document.inquiry.Email.focus();
return false;
}
if(document.inquiry.Telephone_Number.value=="")
{
alert("Please Enter Telephone_Number");
document.inquiry.Telephone_Number.focus();
return false;
}
if(isNaN(document.inquiry.Telephone_Number.value))
{
alert("Please Enter Telephone_Number in Digits");
document.inquiry.Telephone_Number.focus();
return false;
}
if(document.inquiry.date_day.options[document.inquiry.date_day.selectedIndex].value=="DD")
{
alert("Please enter ReservationDay");
return false;
}
if(document.inquiry.date_month.options[document.inquiry.date_month.selectedIndex].value=="MM")
{
alert("Please enter ReservationMonth");
return false;
}
if(document.inquiry.date_year.options[document.inquiry.date_year.selectedIndex].value=="YYYY")
{
alert("Please enter ReservationYear");
return false;
}
if(document.inquiry.Time_of_reservation.value=="")
{
alert("Please Enter Time_of_reservation");
document.inquiry.Time_of_reservation.focus();
return false;
}
return checkmail();
return true;
}
function checkmail()
{
var mi,i;
mi=document.inquiry.Email.value;
if(mi > "")
{
var temp=new Array();
temp=mi.split('@');
if(temp.length > 2)
{
alert("Invalid Email Address");
return false;
}
if(mi.indexOf("@")==-1 || mi.indexOf(".") == -1)
{
alert("Invalid Email Id");
return false;
}
if((mi.indexOf("@")==mi.indexOf(".")-1))
{
alert("Invalid Email Id");
return false;
}
var str = "!#$%^&*()-+/\{}';:`~";
for(i=0;i<str.length;i++)
{
if(mi.indexOf(str.charAt(i)) != -1)
{
alert("Invalid Email Address");
return false;
}
}
}
}
</script>
</head>
<LINK href="form.css" type=text/css rel=stylesheet>
<body topmargin="0" leftmargin="0" bgcolor="#F3F3EC">
<form action="form.asp?flag=1" method="post" name="inquiry">
<table border="0" width="400" cellpadding="0" cellspacing="0" align="center">
<tr>
<td><div align="center"><img src="masala-logo.png" width="110" height="145"></div></td>
<td align="right" valign="bottom" class="smalltext1">
<div align="right"><br>
<br>
<br>
<br>
<span class="style1">Restaurant Booking Form </span></div></td>
</tr>
</table>
<table border="0" width="400" cellpadding="2" cellspacing="0" align="center">
<tr>
<td width="149" class="maintext">
<div align="left">
<label for="Name" class="style3">Full Name:</label>
<span class="style4">*</span> </div> </td>
<td height="25" colspan="2" align="left" valign="middle" class="maintext">
<input name="Name" type="text" class="style2" id="Name" size="40" /></td>
</tr>
<tr>
<td class="maintext">
<div align="left"><label for="Email" class="style3">Email
address:</label>
<span class="style4">*</span></div> </td>
<td height="25" colspan="2" align="left" valign="middle" class="maintext">
<input name="Email" type="text" class="style2" id="Email" size="40" /> </td>
</tr>
<tr>
<td class="maintext">
<div align="left">
<label for="Membership_Number" class="style3">Membership Number:</label>
</div> </td>
<td height="25" colspan="2" align="left" valign="middle" class="maintext" >
<input name="Membership_Number" type="text" class="style2" id="Membership_Number" size="40" /> </td>
</tr>
<tr>
<td class="maintext">
<div align="left">
<label for="Telephone_Number" class="style3">Telephone Number:</label>
<span class="style4">*</span></div> </td>
<td height="25" colspan="2" align="left" valign="middle" class="maintext" >
<input name="Telephone_Number" type="text" class="style2" id="Telephone_Number" size="40" /> </td>
</tr>
<tr>
<td class="maintext">
<div align="left">
<label for="Date_of_reservation" class="style3">Date
of Reservation<br>
(dd/mm/yyyy):</label>
<span class="style4">*</span></div> </td>
<td height="25" colspan="2" align="left" valign="middle" class="maintext" >
<select name="date_day" size=1 id="date_day" class="style2">
<option value="DD" selected>DD</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="date_month" size=1 id="date_month" class="style2">
<option value="MM" selected>MON</option>
<option value="01">Jan </option>
<option value="02">Feb </option>
<option value="03">Mar </option>
<option value="04">Apr </option>
<option value="05">May </option>
<option value="06">Jun </option>
<option value="07">Jul </option>
<option value="08">Aug </option>
<option value="09">Sep </option>
<option value="10">Oct </option>
<option value="11">Nov </option>
<option value="12">Dec</option>
</select>
<select name="date_year" size=1 id="date_year" class="style2">
<option value="YYYY" selected>YYYY</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
</select> </td>
</tr>
<tr>
<td class="maintext">
<div align="left"><label for="Time_of_reservation" class="style3">Time
of Reservation:</label>
<span class="style4">*</span></div> </td>
<td height="25" colspan="2" align="left" valign="middle" class="maintext" >
<input name="Time_of_reservation" type="text" class="style2" id="Time_of_reservation" size="12" />
<select name="meridian" size=1 class="style2">
<option value="AM">AM</option>
<option value="PM">PM</option>
</select>
</td>
</tr>
<tr>
<td class="maintext">
<div align="left"><label for="Number_of_people" class="style3">Number
of People:</label>
<span class="style4">*</span></div> </td>
<td height="25" colspan="2" align="left" valign="middle" class="maintext">
<select name="Number_of_people" class="style2" id="Number_of_people">
<option selected="selected">1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
</select> </td>
</tr>
<tr>
<td valign="top" class="maintext"><label for="further_information" class="style3">Futher Information:</label> </td>
<td height="85" colspan="2" align="left" valign="middle" class="maintext"><textarea name="further_information" cols="40" rows="6" class="style2" id="further_information"></textarea> </td>
</tr>
<tr>
<td rowspan="3" class="maintext"> </td>
<td colspan="2" align="center" valign="middle" class="maintext"><p> </p></td>
</tr>
<tr>
<td width="113" align="center" valign="middle" class="maintext"><input name="submit" type="submit" onClick="return validate();return true;" value="Send Form"/></td>
<td width="126" align="center" valign="middle" class="maintext"><input name="reset" type="reset" value="Reset Form" /></td>
</tr>
<tr>
<td colspan="2" align="center" valign="middle" class="maintext"> </td>
</tr>
</table>
</form>
</body>
</html>
This is the code of my form.
Notice though the <form action="form.asp?flag=1" method="post" name="inquiry">.
Im confused on what that flag=1 is for?
When the submit button is pressed the SAME page loads up (without the values they entered) but now a "Enquiry sent successfully" text shows up.
Im terribly confused on what code they used to do this and very much appriciate if someone could assist me?
Iv brought about using this code for when its updated since i couldnt figure out how to obtain the code they use to send the value by email:
<%
' declare variables
Dim EmailFrom
Dim EmailTo
Dim Subject
Dim Name
Dim Email
Dim Membership_Number
Dim Telephone_Number
Dim Date_of_reservation
Dim Time_of_reservation
Dim Number_of_people
Dim further_information
' get posted data into variables
EmailFrom = Trim(Request.Form("info@masala910.co.uk"))
EmailTo = "info@masala910.co.uk"
Subject = "Restaurant Booking"
Name = Trim(Request.Form("Name"))
Email = Trim(Request.Form("Email"))
Membership_Number = Trim(Request.Form("Membership_Number"))
Telephone_Number = Trim(Request.Form("Telephone_Number"))
Date_of_reservation = Trim(Request.Form("Date_of_reservation"))
Time_of_reservation = Trim(Request.Form("Time_of_reservation"))
Number_of_people = Trim(Request.Form("Number_of_people"))
further_information = Trim(Request.Form("further_information"))
' validation
Dim validationOK
validationOK=true
If (Trim(EmailFrom)="") Then validationOK=false
If (Trim(Name)="") Then validationOK=false
If (Trim(Email)="") Then validationOK=false
If (Trim(Membership_Number)="") Then validationOK=false
If (Trim(Telephone_Number)="") Then validationOK=false
If (Trim(Date_of_reservation)="") Then validationOK=false
If (Trim(Time_of_reservation)="") Then validationOK=false
If (Trim(Number_of_people)="") Then validationOK=false
If (Trim(further_information)="") Then validationOK=false
If (validationOK=false) Then Response.Redirect("error.htm?" & EmailFrom)
' prepare email body text
Dim Body
Body = Body & "A reservation has been made by" & VbCrLf
Body = Body & "Name: " & Name & VbCrLf
Body = Body & "Email: " & Email & VbCrLf
Body = Body & "Telephone Number: " & Telephone_Number & VbCrLf
Body = Body & "Membership Number: " & Membership_Number & VbCrLf
Body = Body & "Date of reservation: " & Date_of_reservation & VbCrLf
Body = Body & "Time of reservation: " & Time_of_reservation & VbCrLf
Body = Body & "Number of people: " & Number_of_people & VbCrLf
Body = Body & "Further Information: " & further_information & VbCrLf
' send email
Dim mail
Set mail = Server.CreateObject("CDONTS.NewMail")
mail.To = EmailTo
mail.From = EmailFrom
mail.Subject = Subject
mail.Body = Body
mail.Send
' redirect to success page
Response.Redirect("needtoedit.htm" & EmailFrom)
%>
If it total bull then please do say:D
Thanks for the help!!
Amrit