/    Sign up×
Community /Pin to ProfileBookmark

Captcha on a Form

This is not working. I want them to have to fill in the information then type in the captcha before they submit so that they are Human ? Here is the code I have. Thank you for any help

<form id=”form1″ name=”form1″ method=”post” action=””>
<p>Wedding Form</p>
<p>First Name
<label for=”first_name”></label>
<input type=”text” name=”first_name” id=”first_name” />
Last Name
<label for=”last_name”></label>
<input type=”text” name=”last_name” id=”last_name” />
</p>
<p>Email:
<label for=”email”></label>
<input type=”text” name=”email” id=”email” />
Phone:
<label for=”phone”></label>
<input type=”text” name=”phone” id=”phone” />
</p>
<p>Which do you prefer: Email or Phone
<label for=”prefered”></label>
<select name=”prefered” id=”prefered”>
<option value=”phone”>phone</option>
<option value=”email”>email</option>
</select>
best time to reach you:
<label for=”time”></label>
<input type=”text” name=”time” id=”time” />
</p>
<p>Wedding Date:
<label for=”date”></label>
<input type=”text” name=”date” id=”date” />
</p>
<p>Wedding Location
<label for=”location”></label>
<input type=”text” name=”location” id=”location” />
</p>
<p>Hours of Coverage
<label for=”hours”></label>
<select name=”hours” id=”hours”>
<option>2</option>
<option>4</option>
<option>6</option>
<option>8</option>
</select>
</p>
<p>Inside or Outside
<label for=”inside_outside”></label>
<select name=”inside_outside” id=”inside_outside”>
<option>Inside</option>
<option>Outside</option>
</select>
</p>
<p>How many people are you expecting.
<label for=”expecting”></label>
<input type=”text” name=”expecting” id=”expecting” />
</p>
<p><?php
ob_start();
session_start();

if(!$_POST[‘submit’]){
echo “<form method=”post” action=”captcha.php”>n”;
echo “<table border=”0″ cellspacing=”3″ cellpadding=”3″>n”;
echo “<tr><td>Type The Letters You See Below Into the Box</td></tr>n”;
echo “<tr><td align=”center”><img src=”image.php”></td></tr>n”;
echo “<tr><td align=”right”><input type=”text” name=”image”></td></tr>n”;

echo “</table></form>n”;

}else {
$image = $_POST[‘image’];

if($image == $_SESSION[‘string’]){
echo “<b>Great success!</b>n”;
}else {
echo “<em>Failure!</em>n”;
}

}

ob_end_flush();
?> &nbsp;</p>
<p>
<input type=”submit” name=”submit” id=”submit” value=”submit” />
</p>
</form>

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@GraniteFeb 09.2011 — You're putting a <form> inside another <form>. I don't think this will ever work.

You'd need to do the actual captcha check after the user submitted the first form.

A tip: You could easily put a really effective captcha system using third party APIs, saving a lot of effort and time.
×

Success!

Help @shutterbug spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...