...

View Full Version : add a capcha on to my contact form



phpcodelearner
02-11-2010, 08:07 PM
hi

what i want to do it to add a capcha on to my contact form the contact form submittes dater to a dater base and sends an email to me.



<?php require_once('../Connections/mywigan.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO email_messages (id, email, subject, message) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['id'], "int"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['subject'], "text"),
GetSQLValueString($_POST['message'], "text"));

mysql_select_db($database_mywigan, $mywigan);
$Result1 = mysql_query($insertSQL, $mywigan) or die(mysql_error());

$insertGoTo = "../index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

?>
<?php

$to = 'someone@somewhere.com';
$subject = $_POST['subject'];
$message = $_POST['message'];
$headers = 'From: emailadress@email.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Email:</td>
<td><input type="text" name="email" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Subject:</td>
<td><input type="text" name="subject" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right" valign="top">Message:</td>
<td><textarea name="message" cols="50" rows="5"></textarea>
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input type="submit" value="submit"></td>
</tr>
</table>
<input type="hidden" name="id" value="">
<input type="hidden" name="MM_insert" value="form1">
</form>

<p>&nbsp;</p>




how would i add a capcha i have been tring to add one for a bit but keep failing.

thanks again :thumbsup:

masterofollies
02-11-2010, 08:11 PM
How complex of a captcha do you need?

ideffect
02-11-2010, 08:15 PM
I'm not sure if you went here (http://recaptcha.net/whyrecaptcha.html) yet but they have a very easy implementation guide/system for php. Read the documentation and if you have any questions, post them.

phpcodelearner
02-11-2010, 08:16 PM
uuuurrrr

i want it a simple as possiable:) but still reasonably secure

thanks agin:thumbsup:

MattF
02-11-2010, 08:34 PM
http://www.phpcaptcha.org/

phpcodelearner
02-11-2010, 09:01 PM
http://www.phpcaptcha.org/

yes i have been here but when i try and to put it in my form i get error i will try agin to put it in my form and post back the results

thanks ever one

JAY6390
02-11-2010, 09:53 PM
recaptcha is by far the best in my opinion

abduraooft
02-12-2010, 08:55 AM
If you are worried about accessibility, textcaptcha (http://textcaptcha.com) is a good alternative and indeed interesting!

phpcodelearner
02-15-2010, 11:51 AM
thanks every one i have got
the
http://www.phpcaptcha.org
one to work it great

thanks again sorry for the late repy:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum