 |
| Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

December 14th, 2004, 04:46 AM
|
|
Registered User
|
|
Join Date: Dec 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
How I can pass parameters to 2 ASP files at ones?
Hi there
I have a form that it has to be filed in Arabic and I want the data of this form to be sent by email as well as to be written to an access database.
form.html ==> email.asp
==> data.asp
I thought to do them in one ASP file. But the problem is each file of them need to have different header, as shown bellow:
email.asp <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
data.asp <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%>
because if these headers are not provided as they are, the Arabic characters will be massy. So I thought to pass the parameters to the both of the files at ones but i did not know how to do it.
|
|

December 14th, 2004, 05:59 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
If passing the variables using querystring-parametres isn't a problem you can just response.redirect from one to the other...
I would call the data.asp-file first, so you only send out the email if the data was succesfully added to the db.
|
|

December 15th, 2004, 12:38 AM
|
|
Registered User
|
|
Join Date: Dec 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Dear Jonax
Thanks for your replay. But I have done this. But the problem is, when I data passed to the data.asp and written to the database, some how it is not passed to the email.asp. So there will be no data to me transmitted. So I just thought to include my codes here:
********
*data.asp*
********
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%>
<%
'****************************
'*Database code for course requests*
'****************************
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsAddComments 'Holds the recordset for the new record to be added to the database
Dim strSQL 'Holds the SQL query for the database
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("results.mdb")
'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=results"
'Create an ADO recordset object
Set rsAddComments = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT data.Name, data.Tel, data.Email, data.Qualification, data.College, data.Department FROM data;"
'Set the cursor type we are using so we can navigate through the recordset
rsAddComments.CursorType = 2
'Set the lock type so that the record is locked by ADO when it is updated
rsAddComments.LockType = 3
'Open the tblComments table using the SQL query held in the strSQL varaiable
rsAddComments.Open strSQL, adoCon
'Tell the recordset we are adding a new record to it
rsAddComments.AddNew
'Add a new record to the recordset
rsAddComments.Fields("Name") = Request.Form("name")
rsAddComments.Fields("Tel") = Request.Form("tel")
rsAddComments.Fields("Email") = Request.Form("email")
rsAddComments.Fields("Qualification") = Request.Form("qual")
rsAddComments.Fields("College") = Request.Form("college")
rsAddComments.Fields("Department") = Request.Form("dep")
'Write the updated recordset to the database
rsAddComments.Update
'Reset server objects
rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing
'Redirect to the confirmation page
Response.Redirect "email.asp"
%>
=============================================
*********
*email.asp*
*********
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim formName, formTel, formEmail, formQual, formCollege, formDep
'define the parameters which comming from the form
formName = Request.Form("name")
formTel = Request.Form("tel")
formEmail = Request.Form("email")
formQual = Request.Form("qual")
formCollege = Request.Form("college")
formDep = Request.Form("dep")
'*****************
'*email massage code *
'*****************
Dim MyCDONTSMail2
Dim HTML
Set MyCDONTSMail2 = CreateObject("CDONTS.NewMail")
HTML = "<!DOCTYPE HTML PUBLIC""-//IETF//DTD HTML//EN"">"
HTML = HTML & "<html>"
HTML = HTML & "<head>"
HTML = HTML & "<meta http-equiv=""Content-Type"" content=""text/html; charset=windows-1252"">"
HTML = HTML & "</head>"
HTML = HTML & "<body>"
HTML = HTML & " <table border=""0"" cellpadding=""0"" cellspacing=""0"" style=""border-collapse: collapse"" bordercolor=""#111111"" width=""59%"" id=""AutoNumber1"" height=""271"">"
HTML = HTML & " <tr>"
HTML = HTML & " <td width=""73%"" height=""27"" colspan=""3"">"
HTML = HTML & " <h1 align=""center"">Course form Results</h1>"
HTML = HTML & " </td>"
HTML = HTML & " </tr>"
HTML = HTML & " <tr>"
HTML = HTML & " <td width=""17%"" height=""27""> </td>"
HTML = HTML & " <td width=""42%"" height=""27"">Name:</td>"
HTML = HTML & " <td width=""22%"" height=""27"" align=""left"">"
HTML = HTML & " " & formName & "</td>"
HTML = HTML & " </tr>"
HTML = HTML & " <tr>"
HTML = HTML & " <td width=""17%"" height=""27""> </td>"
HTML = HTML & " <td width=""42%"" height=""27"">Telephone:</td>"
HTML = HTML & " <td width=""22%"" height=""27"" align=""left"">"
HTML = HTML & " " & formTel & "</td>"
HTML = HTML & " </tr>"
HTML = HTML & " <tr>"
HTML = HTML & " <td width=""17%"" height=""27""> </td>"
HTML = HTML & " <td width=""42%"" height=""27"">Email_Address:</td>"
HTML = HTML & " <td width=""22%"" height=""27"" align=""left"">"
HTML = HTML & " " & formEmail & "</td>"
HTML = HTML & " </tr>"
HTML = HTML & " <tr>"
HTML = HTML & " <td width=""17%"" height=""27""> </td>"
HTML = HTML & " <td width=""42%"" height=""27"">Qualification:</td>"
HTML = HTML & " <td width=""22%"" height=""27"" align=""left"">"
HTML = HTML & " " & formQual & "</td>"
HTML = HTML & " </tr>"
HTML = HTML & " <tr>"
HTML = HTML & " <td width=""17%"" height=""27""> </td>"
HTML = HTML & " <td width=""42%"" height=""27"">College:</td>"
HTML = HTML & " <td width=""22%"" height=""27"" align=""left"">"
HTML = HTML & " " & formCollege & "</td>"
HTML = HTML & " </tr>"
HTML = HTML & " <tr>"
HTML = HTML & " <td width=""17%"" height=""27""> </td>"
HTML = HTML & " <td width=""42%"" height=""27"">Department:</td>"
HTML = HTML & " <td width=""22%"" height=""27"" align=""left"">"
HTML = HTML & " " & formDep & "</td>"
HTML = HTML & " </tr>"
HTML = HTML & " <tr>"
HTML = HTML & " <td width=""51%"" height=""28"" colspan=""2""> </td>"
HTML = HTML & " <td width=""22%"" height=""28"" align=""left""> </td>"
HTML = HTML & " </tr>"
HTML = HTML & " </table>"
HTML = HTML & "</body>"
HTML = HTML & "</html>"
MyCDONTSMail2.From= formEmail1
MyCDONTSMail2.To="****@*****"
'MyCDONTSMail2.BCC="****@*****"
MyCDONTSMail2.Subject="(" & formName & ") Requests a seat in "
MyCDONTSMail2.BodyFormat=0
MyCDONTSMail2.MailFormat=0
MyCDONTSMail2.Body=HTML
MyCDONTSMail2.Send
set MyCDONTSMail2=nothing
'Redirect to the confirmation page
Response.Redirect "confirmation.html"
%>
|
|

December 15th, 2004, 04:04 AM
|
|
Registered User
|
|
Join Date: Dec 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi there
I would like to thank those who tried to help me. And I would like to share you what I have achieved. In short, I have done it by making a form inside the data.asp file, which reads the data at the first step and then passes it to the email.asp file as another form but with the sent data only using an auto submit method at the first file. Any way, I am not going to confuse you, you can follow the codes that I have done and hoping you get what I mean.
===========
*********
*email.asp*
*********
<html>
<body>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%>
<%
Dim formName, formTel, formEmail, formQual, formCollege, formDep
'define the parameters which comming from the form
formName = Request.Form("name")
formTel = Request.Form("tel")
formEmail = Request.Form("email")
formQual = Request.Form("qual")
formCollege = Request.Form("college")
formDep = Request.Form("dep")
'****************************
'*Database code for course requests*
'****************************
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsAddComments 'Holds the recordset for the new record to be added to the database
Dim strSQL 'Holds the SQL query for the database
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("results.mdb")
'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=results"
'Create an ADO recordset object
Set rsAddComments = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT data.Name, data.Tel, data.Email, data.Qualification, data.College, data.Department FROM data;"
'Set the cursor type we are using so we can navigate through the recordset
rsAddComments.CursorType = 2
'Set the lock type so that the record is locked by ADO when it is updated
rsAddComments.LockType = 3
'Open the tblComments table using the SQL query held in the strSQL varaiable
rsAddComments.Open strSQL, adoCon
'Tell the recordset we are adding a new record to it
rsAddComments.AddNew
'Add a new record to the recordset
rsAddComments.Fields("Name") = Request.Form("name")
rsAddComments.Fields("Tel") = Request.Form("tel")
rsAddComments.Fields("Email") = Request.Form("email")
rsAddComments.Fields("Qualification") = Request.Form("qual")
rsAddComments.Fields("College") = Request.Form("college")
rsAddComments.Fields("Department") = Request.Form("dep")
'Write the updated recordset to the database
rsAddComments.Update
'Reset server objects
rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing
%>
<form name="request" method="POST" action="email.asp" dir="ltr">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="104%" id="AutoNumber1" height="271">
<tr>
<td width="32%" height="27">Name:</td>
<td width="29%" height="27" align="center">
<input type="text" name="name" value="<%Response.Write formName %>" size="36"></td>
</tr>
<tr>
<td width="32%" height="27">Telephone:</td>
<td width="29%" height="27" align="center">
<input type="text" name="tel" value="<%Response.Write formTel %>" size="36"></td>
</tr>
<tr>
<td width="32%" height="27">Email Address:</td>
<td width="29%" height="27" align="center">
<input type="text" name="email" value="<%Response.Write formEmail %>" size="36"></td>
</tr>
<tr>
<td width="32%" height="27">Qualification:</td>
<td width="29%" height="27" align="center">
<input type="text" name="qual" value="<%Response.Write formQual %>" size="36"></td>
</tr>
<tr>
<td width="32%" height="27">College:</td>
<td width="29%" height="27" align="center">
<select size="1" name="college">
<option selected><%Response.Write formCollege %></option>
</select></td>
</tr>
<tr>
<td width="32%" height="27">Department:</td>
<td width="29%" height="27" align="center">
<input type="text" name="dep" value="<%Response.Write formDep %>" size="36"></td>
</tr>
</table>
</form>
<SCRIPT LANGUAGE="Javascript">
<!--
//document.forms("formName").submit()
document.forms("request").submit()
//--></SCRIPT>
</body>
</html>
=========================================
=========================================
*********
*email.asp*
*********
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim formName, formTel, formEmail, formQual, formCollege, formDep
'define the parameters which comming from the form
formName = Request.Form("name")
formTel = Request.Form("tel")
formEmail = Request.Form("email")
formQual = Request.Form("qual")
formCollege = Request.Form("college")
formDep = Request.Form("dep")
'**********
'*email code *
'**********
Dim MyCDONTSMail2
Dim HTML
Set MyCDONTSMail2 = CreateObject("CDONTS.NewMail")
HTML = "<!DOCTYPE HTML PUBLIC""-//IETF//DTD HTML//EN"">"
HTML = HTML & "<html>"
HTML = HTML & "<head>"
HTML = HTML & "<meta http-equiv=""Content-Type"" content=""text/html; charset=windows-1252"">"
HTML = HTML & "</head>"
HTML = HTML & "<body>"
HTML = HTML & " <table border=""0"" cellpadding=""0"" cellspacing=""0"" style=""border-collapse: collapse"" bordercolor=""#111111"" width=""59%"" id=""AutoNumber1"" height=""271"">"
HTML = HTML & " <tr>"
HTML = HTML & " <td width=""73%"" height=""27"" colspan=""3"">"
HTML = HTML & " <h1 align=""center"">Course form Results</h1>"
HTML = HTML & " </td>"
HTML = HTML & " </tr>"
HTML = HTML & " <tr>"
HTML = HTML & " <td width=""17%"" height=""27""> </td>"
HTML = HTML & " <td width=""42%"" height=""27"">Name:</td>"
HTML = HTML & " <td width=""22%"" height=""27"" align=""left"">"
HTML = HTML & " " & formName & "</td>"
HTML = HTML & " </tr>"
HTML = HTML & " <tr>"
HTML = HTML & " <td width=""17%"" height=""27""> </td>"
HTML = HTML & " <td width=""42%"" height=""27"">Telephone:</td>"
HTML = HTML & " <td width=""22%"" height=""27"" align=""left"">"
HTML = HTML & " " & formTel & "</td>"
HTML = HTML & " </tr>"
HTML = HTML & " <tr>"
HTML = HTML & " <td width=""17%"" height=""27""> </td>"
HTML = HTML & " <td width=""42%"" height=""27"">Email_Address:</td>"
HTML = HTML & " <td width=""22%"" height=""27"" align=""left"">"
HTML = HTML & " " & formEmail & "</td>"
HTML = HTML & " </tr>"
HTML = HTML & " <tr>"
HTML = HTML & " <td width=""17%"" height=""27""> </td>"
HTML = HTML & " <td width=""42%"" height=""27"">Qualification:</td>"
HTML = HTML & " <td width=""22%"" height=""27"" align=""left"">"
HTML = HTML & " " & formQual & "</td>"
HTML = HTML & " </tr>"
HTML = HTML & " <tr>"
HTML = HTML & " <td width=""17%"" height=""27""> </td>"
HTML = HTML & " <td width=""42%"" height=""27"">College:</td>"
HTML = HTML & " <td width=""22%"" height=""27"" align=""left"">"
HTML = HTML & " " & formCollege & "</td>"
HTML = HTML & " </tr>"
HTML = HTML & " <tr>"
HTML = HTML & " <td width=""17%"" height=""27""> </td>"
HTML = HTML & " <td width=""42%"" height=""27"">Department:</td>"
HTML = HTML & " <td width=""22%"" height=""27"" align=""left"">"
HTML = HTML & " " & formDep & "</td>"
HTML = HTML & " </tr>"
HTML = HTML & " <tr>"
HTML = HTML & " <td width=""51%"" height=""28"" colspan=""2""> </td>"
HTML = HTML & " <td width=""22%"" height=""28"" align=""left""> </td>"
HTML = HTML & " </tr>"
HTML = HTML & " </table>"
HTML = HTML & "</body>"
HTML = HTML & "</html>"
MyCDONTSMail2.From= formEmail
MyCDONTSMail2.To="****@********"
MyCDONTSMail2.BCC="****@********"
MyCDONTSMail2.Subject="(" & formName & ") Requests a seat in "
MyCDONTSMail2.BodyFormat=0
MyCDONTSMail2.MailFormat=0
MyCDONTSMail2.Body=HTML
MyCDONTSMail2.Send
set MyCDONTSMail2=nothing
'Redirect to the confirmation page
Response.Redirect "confirmation.html"
%>
|
|

December 15th, 2004, 05:20 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
A few notes of caution:
I considered the solution you ended up with, it will NOT work if the client has javascript disabled. Also, it seems you have placed your database within your public webfolder, which is a VERY BAD idea - it will allow people to download the file by entering http://yoururl/results.mdb in their browser.
|
|
 |