Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Novice needs extreme help

New Here ,
Feb 25, 2009 Feb 25, 2009
Hello Community, I am quite a novice when it comes to all of this. I was wanting to create a contact form on my website and have some validation and also wanting to place a captcha at the end. I want to be able to email the form submissions to my email rather than loading them to a database. Also I would like to know if it is possible to made a field that someone can enter a promotional code and validate to see if it's an active offer?

Any ideas, tutorials, or ways of doing this would be extremely helpful. Thanks in advance.
230
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 26, 2009 Feb 26, 2009
LATEST
Well, first of all, you have to ask yourself what it is exactly you will be validating. Validation for example could be as simple as making sure at least one character is entered, or it could be as complicated as checking if an email address entered is valid.

Sometimes, you might have several different types of validation even on the same field...for exmaple an email address. You want to make sure the email is entered, and then you want to make sure it's a valid email and then you might further still want to make sure this email is only from a certain domain. It can all be as complex as you want it to be.

I have done you an example, but it is only checking one field and that something is entered. Try submitting it with text AND then try submitting it without - you should soon see how the logic is constructed. Hopefully this will give you a basic idea of how to build form logic.

In terms of a captcha, if you're using CF8, you can use the CFIMAGE tag, it has a captcha feature.

In terms of sending an email, check out the CFMAIL tag.

In terms of a voucher code and checking its validity, you might need a database to compare it to, or you could perhaps hard code it - it's up to you.


<cfif isDefined("form.exampleSubmit")>

<cfif not len(form.exampleText)>
<p>The field is empty!</p>
<cfelse>
<p>You wrote: <cfoutput>#form.exampleText#</cfoutput></p>
</cfif>

</cfif>


<form action="<cfoutput>#cgi.script_name#</cfoutput>" method="post">

<input type="text" name="exampleText" value="" />
<input type="submit" name="exampleSubmit" value="Submit Form" />

</form>

Good luck,
Mikey.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources