Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can anyone point me to a validation form? 1

Status
Not open for further replies.

danielh68

Technical User
Jul 31, 2001
431
US
Hi.

I have trying to to do this tutorial at
As usual, I'm having problems. When I attempt to create an ODBC it states my path directory is invalid. First of all, I don't know why. Second, does the directory that I assign on my local drive have any relevance to the directory on the server?

What I'm really trying to do is create a page that the user must input an email address before proceeding to the next page. In additon, I would like the addresses to be saved in a database. Does anyone know of any other tutorials that address this?


Much appreciated.
Dan
 
try this
<%
'Create a connection to our database
Set cnn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set rst = Server.CreateObject(&quot;ADODB.Recordset&quot;)

'open your connection using a connection string
cnn.Open &quot;driver={Microsoft Access Driver (*.mdb)};;DBQ=&quot; & Server.Mappath(&quot;/name.dbm&quot;)

sqltext = &quot;SELECT * FROM tblName&quot;
rst.Open sqltext,cnn,3,3

Dim mail
mail = Request.Form(&quot;email&quot;)
rst.AddNew
if email = &quot;&quot; then
response.redirect &quot;error.asp&quot;
else
rst(&quot;email&quot;) = mail
response.redirect &quot;next page.asp&quot;
rst.Update

rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
%>
[bomb]
I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
admin@onpntwebdesigns.com
 
Hi onpnt,

I uploaded the code you provided with some minor changes. Plus, I have .mdb table just with an email column and ID. However I got this error:

Microsoft VBScript compilation error '800a03f6'

Expected 'End'

/proto/test.asp, line 32


By the way, here's the code I tweaked:

<%
'Create a connection to our database
Set cnn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set rst = Server.CreateObject(&quot;ADODB.Recordset&quot;)

'open your connection using a connection string
cnn.Open &quot;driver={Microsoft Access Driver (*.mdb)};;DBQ=&quot; & Server.Mappath(&quot;/testdata/mydatabase.mdb&quot;)<---changed

sqltext = &quot;SELECT * FROM tblEmail&quot; <---changed
rst.Open sqltext,cnn,3,3

Dim mail
mail = Request.Form(&quot;email&quot;)
rst.AddNew
if email = &quot;&quot; then
response.redirect &quot;error.htm&quot; <---changed
else
rst(&quot;email&quot;) = mail
response.redirect &quot;success.htm&quot; <---changed
rst.Update

rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
%>

Any suggestions?

Thank You,
DanH
 
you know I apologize. I had all kinds of sloppy typos in there you found. The error is because I didn't state the end if....here
if email = &quot;&quot; then
response.redirect &quot;error.htm&quot; <---changed
else
rst(&quot;email&quot;) = mail
response.redirect &quot;success.htm&quot; <---changed
end if

the whole dbm or whatever I typed is embarrising[lol]

hope that solves it for you.

[bomb]
I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
admin@onpntwebdesigns.com
 
Hi onpnt,

I added the &quot;end if&quot; statement, but for some reason my page goes directly to the error.htm page. Here' my code again, I place comment/questions on the side that I'm a little confused about. Please, only look at this at your convenience. Thanks.

Code:

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
<input type=&quot;text&quot; name=&quot;yourEmail&quot;>

<%
'Create a connection to our database
Set cnn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set rst = Server.CreateObject(&quot;ADODB.Recordset&quot;)

'open your connection using a connection string
cnn.Open &quot;driver={Microsoft Access Driver (*.mdb)};;DBQ=&quot; & Server.Mappath(&quot;/testdata/mydatabase.mdb&quot;)

'this populates my table with visitor's email
sqltext = &quot;SELECT * FROM Email&quot;

'executes the command?
rst.Open sqltext,cnn,3,3

Dim mail

'sends form data from input box to the table
mail = Request.Form(&quot;yourEmail&quot;)

'not sure
rst.AddNew

'if I enter nothing and hit submit I will be redirected to error.htm
if yourEmail = &quot;&quot; then
response.redirect &quot;error.htm&quot;
else

'if I enter an email address it takes me to success.htm/table is populated
rst(&quot;yourEmail&quot;) = mail
response.redirect &quot;success.htm&quot;
rst.Update
end if

rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
%>

Thanks, again.

danH
 
dan you're not calling the variable in the if statements
change it to this
Search Find A Forum Keyword Search
Find An Expert Advanced Search

Home > Forum Areas > Programmers > Graphics & Web Tools > Microsoft: Active Server Pages (ASP) Forum
Can anyone point me to a validation form?
thread333-319065



Read
New Posts Reply To
This Thread
E-mail It
Print It Next
Thread
danielh68 (TechnicalUser) Jul 22, 2002
Hi.

I have trying to to do this tutorial at
As usual, I'm having problems. When I attempt to create an ODBC it states my path directory is invalid. First of all, I don't know why. Second, does the directory that I assign on my local drive have any relevance to the directory on the server?

What I'm really trying to do is create a page that the user must input an email address before proceeding to the next page. In additon, I would like the addresses to be saved in a database. Does anyone know of any other tutorials that address this?


Much appreciated.
Dan


Mark this post as a helpful/expert post!


Inappropriate post?
If so, Red Flag it!


Check out the FAQ
area for this forum!


onpnt (Programmer) Jul 22, 2002
try this
<%
'Create a connection to our database
Set cnn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set rst = Server.CreateObject(&quot;ADODB.Recordset&quot;)

'open your connection using a connection string
cnn.Open &quot;driver={Microsoft Access Driver (*.mdb)};;DBQ=&quot; & Server.Mappath(&quot;/name.dbm&quot;)

sqltext = &quot;SELECT * FROM tblName&quot;
rst.Open sqltext,cnn,3,3

Dim mail
mail = Request.Form(&quot;email&quot;)
rst.AddNew
if email = &quot;&quot; then
response.redirect &quot;error.asp&quot;
else
rst(&quot;email&quot;) = mail
response.redirect &quot;next page.asp&quot;
rst.Update

rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
%>


I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
admin@onpntwebdesigns.com





Inappropriate post?
If so, Red Flag it!


Check out the FAQ
area for this forum!


danielh68 (TechnicalUser) Jul 22, 2002
Hi onpnt,

I uploaded the code you provided with some minor changes. Plus, I have .mdb table just with an email column and ID. However I got this error:

Microsoft VBScript compilation error '800a03f6'

Expected 'End'

/proto/test.asp, line 32


By the way, here's the code I tweaked:

<%
'Create a connection to our database
Set cnn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set rst = Server.CreateObject(&quot;ADODB.Recordset&quot;)

'open your connection using a connection string
cnn.Open &quot;driver={Microsoft Access Driver (*.mdb)};;DBQ=&quot; & Server.Mappath(&quot;/testdata/mydatabase.mdb&quot;)<---changed

sqltext = &quot;SELECT * FROM tblEmail&quot; <---changed
rst.Open sqltext,cnn,3,3

Dim mail
mail = Request.Form(&quot;email&quot;)
rst.AddNew
if email = &quot;&quot; then
response.redirect &quot;error.htm&quot; <---changed
else
rst(&quot;email&quot;) = mail
response.redirect &quot;success.htm&quot; <---changed
rst.Update

rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
%>

Any suggestions?

Thank You,
DanH


Mark this post as a helpful/expert post!


Inappropriate post?
If so, Red Flag it!


Check out the FAQ
area for this forum!


onpnt (Programmer) Jul 22, 2002
you know I apologize. I had all kinds of sloppy typos in there you found. The error is because I didn't state the end if....here
if email = &quot;&quot; then
response.redirect &quot;error.htm&quot; <---changed
else
rst(&quot;email&quot;) = mail
response.redirect &quot;success.htm&quot; <---changed
end if

the whole dbm or whatever I typed is embarrising

hope that solves it for you.



I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
admin@onpntwebdesigns.com





Inappropriate post?
If so, Red Flag it!


Check out the FAQ
area for this forum!


danielh68 (TechnicalUser) Jul 23, 2002
Hi onpnt,

I added the &quot;end if&quot; statement, but for some reason my page goes directly to the error.htm page. Here' my code again, I place comment/questions on the side that I'm a little confused about. Please, only look at this at your convenience. Thanks.

Code:

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
<input type=&quot;text&quot; name=&quot;yourEmail&quot;>

<%
'Create a connection to our database
Set cnn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set rst = Server.CreateObject(&quot;ADODB.Recordset&quot;)

'open your connection using a connection string
cnn.Open &quot;driver={Microsoft Access Driver (*.mdb)};;DBQ=&quot; & Server.Mappath(&quot;/testdata/mydatabase.mdb&quot;)

'this populates my table with visitor's email
sqltext = &quot;SELECT * FROM Email&quot;

'executes the command?
rst.Open sqltext,cnn,3,3

Dim mail

'sends form data from input box to the table
mail = Request.Form(&quot;yourEmail&quot;)

'not sure
rst.AddNew

'if I enter nothing and hit submit I will be redirected to error.htm
if mail = &quot;&quot; then
response.redirect &quot;error.htm&quot;
else

'if I enter an email address it takes me to success.htm/table is populated
rst(&quot;yourEmail&quot;) = mail
response.redirect &quot;success.htm&quot;
rst.Update
end if

the reason it was always redirecting to error was because yourEmail was not declared with a value so indeed it was = &quot;&quot; in that meeting the condition and redirecting to the error.asp

let me know how that goes
[bomb]
I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
admin@onpntwebdesigns.com
 
oops copy and pasted alittle too much there[lol]


Dim mail

'sends form data from input box to the table
mail = Request.Form(&quot;yourEmail&quot;)

'not sure
rst.AddNew

'if I enter nothing and hit submit I will be redirected to error.htm
if mail = &quot;&quot; then
response.redirect &quot;error.htm&quot;
else

'if I enter an email address it takes me to success.htm/table is populated
rst(&quot;yourEmail&quot;) = mail
response.redirect &quot;success.htm&quot;
rst.Update
end if

the reason it was always redirecting to error was because yourEmail was not declared with a value so indeed it was = &quot;&quot; in that meeting the condition and redirecting to the error.asp

let me know how that goes [bomb]
I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
admin@onpntwebdesigns.com
 
So do I state something like yourEmail <> &quot;&quot; then do this. Is that kind of what you mean?

Thanks,
Dan
 
In addition, I'm doing lessons from a Sam's 24 hour book. And, I doing this lesson on a simple email script:

<% @LANGUAGE = VBScript %>
<%
Option Explicit
Dim myMail
Set myMail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
myMail.Send &quot;danielh68@sierratel.com&quot;, _ &quot;My first mail&quot;, 0
Set myMail = Nothing
%>

I know my host doesn't provide CDONTS, they recommended I insert SMTPsvg.mailer instead. Yet, it still doesn't work. Do you or anyone have any suggestions, besides throwing in the towel?

Thanks again,
DanH
 
here's a explaination for whats going on

Dim maildeclare the variable to hold the email value

'sends form data from input box to the table
mail = Request.Form(&quot;yourEmail&quot;)
above is where we give the value of the email filled into the form to the variable mail

rst.AddNew we start the addnew to insert the email to the DB

if mail = &quot;&quot; then
this states that if the variable mail which holds the value of the users email is blank or null then they get redirected
response.redirect &quot;error.htm&quot;
elseif not then go on

rst(&quot;yourEmail&quot;) = mail
we just inserted the mail variable which holds the email into the DB

response.redirect &quot;success.htm&quot;

rst.Update
update the DB to finalize everything
end if

hope that helps out. [bomb]
I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
admin@onpntwebdesigns.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top