473,378 Members | 1,236 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

asp server

Can anyone help me?

I am doing a simple form for email and I want to validate it?
All the tutorials say I should use the following

<%
If request.form("name")="" or request.form("email")="" then
response.redirect "form.asp"
response.end
End if
%>

trouble is the server runs this code before the page loads and so the
page simply hangs and never loads as it always tries to redirect due to
the form elements initially being blank.

I could cheat and put in <yourname> in the name column but I cant
select a default value for my radio buttons.

thanks in advance,

menelty.

Dec 20 '05 #1
3 1327
<%
sPosted = Request.Querystring("lPost")
Select Case sPosted
Case "1" '// Posted
sName = Request.Form("txtName"): If Len(sName) < 1 Then Response.Redirect
"myform.asp?l=2"
sMail = Request.Form("txtMail"): If Len(sMail) < 1 Then Response.Redirect
"myform.asp?l=2"
'// Process the form
Response.Write "<b>Name:</b> " & sName & "<br>"
Response.Write "<b>Mail:</b> " & sMail & "<br>"
'// Notify after post
Response.Write "Thankyou, your comments have been sent"
Case Else '// Show the form
If sPosted = "2" Then Response.Write "<font color=""#ff0000""><b>Error:
you did something wrong ...</b></font><br><br>"
%>
<form
action="myform.asp?lpost=1&sid=<%=Request.ServerVa riables("REMOTE_ADDR")%>"
method="post">
<input type="text" name="txtName"><input type="text" name="txtMail">
<input type="submit" name="submit" value="Submit">
</form>
<%
End Select
%>

Example:
http://mysteryfcm.plus.com/misc/myform.asp

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

<me*****@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Can anyone help me?

I am doing a simple form for email and I want to validate it?
All the tutorials say I should use the following

<%
If request.form("name")="" or request.form("email")="" then
response.redirect "form.asp"
response.end
End if
%>

trouble is the server runs this code before the page loads and so the
page simply hangs and never loads as it always tries to redirect due to
the form elements initially being blank.

I could cheat and put in <yourname> in the name column but I cant
select a default value for my radio buttons.

thanks in advance,

menelty.

Dec 20 '05 #2
here is a working one that is ready to go.. might help you learn
http://www.powerasp.com/content/new/...ing_cdosys.asp
<me*****@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Can anyone help me?

I am doing a simple form for email and I want to validate it?
All the tutorials say I should use the following

<%
If request.form("name")="" or request.form("email")="" then
response.redirect "form.asp"
response.end
End if
%>

trouble is the server runs this code before the page loads and so the
page simply hangs and never loads as it always tries to redirect due to
the form elements initially being blank.

I could cheat and put in <yourname> in the name column but I cant
select a default value for my radio buttons.

thanks in advance,

menelty.

Dec 20 '05 #3
me*****@gmail.com wrote:
Can anyone help me?

I am doing a simple form for email and I want to validate it?
All the tutorials say I should use the following

<%
If request.form("name")="" or request.form("email")="" then
response.redirect "form.asp"
response.end
End if
%>

trouble is the server runs this code before the page loads and so the
page simply hangs and never loads as it always tries to redirect due to
the form elements initially being blank.

I could cheat and put in <yourname> in the name column but I cant
select a default value for my radio buttons.

thanks in advance,

menelty.


The simplest way is to check to see if the form's Submit button has
been pressed:

<%
If Request.Form("Submit") = "Submit" then
If Request.Form("name")="" or Request.Form("email")="" then
response.redirect "form.asp"
Else
'....process the form's content....
End if
End if
%>

However, this isn't very helpful. The visitor will just be presented
with a blank form again, so ideally you create a variable called
something like errormsg and apply the value "You didn't complete your
user name or email" and then write that to the page above the
re-presented form.
<%
If Request.Form("Submit") = "Submit" then
If Request.Form("name")="" or Request.Form("email")="" then
errormsg = "You didn't complete your user name or email"
Else
'....process the form's content....
End if
End if
Response.write errormsg
%>
/P.

Dec 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Phil | last post by:
I am using a Pascal like language (Wealth-Lab) on W2K and call this server: class HelloWorld: _reg_clsid_ = "{4E797C6A-5969-402F-8101-9C95453CF8F6}" _reg_desc_ = "Python Test COM Server"...
6
by: Nathan Sokalski | last post by:
I want to set up SQL Server on Windows XP Pro so that I can use the database capabilities of ASP and IIS. I am probably using some incorrect settings, but I am not sure what they are. Here is what...
9
by: Grim Reaper | last post by:
My work let me put SQL Server 7.0 Enterprise Edition on my laptop. I have never setup a server from the beginning, so I am a little new at creating server groups. Alright, I am trying to create...
0
by: Chris Halcrow | last post by:
Hi I've spent ALL DAY trying to re-install SQL Server 2000 on Windows XP. I continually get the error 'cannot configure server' just at the end of the installation. I've tried the following: ...
0
by: Zorba.GR | last post by:
IBM DB2 Connect Enterprise Edition v8.2, other IBM DB2 (32 bit, 64 bit) (MULTiOS, Windows, Linux, Solaris), IBM iSoft Commerce Suite Server Enterprise v3.2.01, IBM Tivoli Storage Resource Manager...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
14
by: Developer | last post by:
Hello All, i have recently installed VS2005 and was trying to install SQL sever 2000. I have Win XP' SP2. But when I tried installing, it only installed client tools and not the database. Can...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.