Solved

PHP captcha code

Posted on 2010-08-18
2
264 Views
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
0
Comment
Question by:Braveheartli
2 Comments
 
LVL 109

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.
0
 
LVL 3

Accepted Solution

by:
grantunwin earned 250 total points
ID: 33464421
add an 'elseif' to your 'if' statement like this:
<?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);
} 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

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

809 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