Jump to content

How to write a condition


Skemcin

Recommended Posts

Ok, so I've written my first ASP form - arggg I much prefer coldfusion. But anyway, its a very simple from, subject, comments form page (email-form.asp) and the action page (email-action.asp) sends it off as it should. However, when I code these pages in coldfusion, I wrap the entire action around a condition. In the form page, I have a hidden field called frm_toemail that is default with no value. So, on my action page, I want my whole page wrapped in a condition that will only process the page if the frm_toemail is still blank.In ColdFusion it would look like this:<cfif form.frm_toemail IS "">doallmyformprocessing<cfelse>abort pagesend message</cfif>Thanks in advance.

Link to comment
Share on other sites

ASP Fundamentals:Anything wrapped in the <% ... %> tags is processed server side, that's where all of your form processing takes place. Anything outside is printed to screen, just like a normal HTML document:

<%' stuff in this block will be processed by the server%><!-- stuff outside of the block is boring old HTML -->

Conditionals in ASP look like this:

<% If condition = true then'... do stuffEnd if %>

To read form data, use:

Request("someFormData")

So, putting it all together:

<%if Request("frm_toemail") <> "" then	' do all of your form processing here%>	Put all of your HTML here.<%else	'abort page%>	Put an error message here.<%end if%>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...