PHP captcha code

Posted on 2010-08-18
Last Modified: 2013-12-13
Dear Experts,

          <?php if (isset($_GET["hdwmsg"]) && $_GET["hdwmsg"] == "invalid") echo chr(60)."font color=red".chr(62)."Please, enter the correct security code.".chr(60)."/font".chr(62);
I want to end it if the security code is not ok.
What should I do?
I'm submiting the form on the same page..
I insert the data to my database and send an email after this code,
if I write security code wrong I receive this error message but it "Please, enter the correct security code." But it doesn't stop there.. it goes below and insert the data and sends email..
thank you
Question by:Braveheartli
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 33464197
"it goes below and insert the data and sends email.."

Obviously you have an error in your logic!

You can use the php function die() to stop the script from executing any more instructions.

Accepted Solution

grantunwin earned 250 total points
ID: 33464421
add an 'elseif' to your 'if' statement like this:
if (isset($_GET["hdwmsg"]) && $_GET["hdwmsg"] == "invalid") {
     echo chr(60)."font color=red".chr(62)."Please, enter the correct security code.".chr(60)."/font".chr(62);
} elseif (isset($_GET["hdwmsg"]){

/* add the code here that inserts the data and sends the email. This will not be executed if the first if statement is satisfied. Solving your problem */


Open in new window


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How would I construct this INSERT statement in PDO? 6 33
MySQL limit and not so limited 13 41
Length of for loop to be dynamic 2 33
xml with php question 5 37
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Introduction This article is intended for those who are new to PHP error handling (  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question