Solved

PHP captcha code

Posted on 2010-08-18
2
260 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 108

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now