Jump to content

Recommended Posts

I am in no way up to making the form myself,it was a script I got off the internet 12 months ago that I have been running but is now hit with spam.

 

My comment script:

 

// connect to database
$dbh = mysql_connect ($db_hostname, $db_username, $db_pass) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db_name);


$tuturl = $_POST["tuturl"];
$tutid2 = $_POST["tutid2"];
$name = $_POST["name"];
$url = $_POST["url"];
$email = $_POST["email"];
$message = $_POST["message"];

$sendcomment = mysql_query("INSERT INTO comments SET tutorialid='$tutid2', name='$name', url='$url', email='$email', comment='$message', date=now()");
if($sendcomment){
//header("Location: $tuturl");
echo "<h1>Submission Successful</h1>";
echo "Your comment has been submitted to admin for consideration. You will now be redirected back to the last page you visited.  Thanks!";
echo "<meta http-equiv='refresh' content='2;URL=$tuturl'>";
} else {
echo "There was an error with the submission. ";
}

?>

 

And this is the captcha script:

<html>
<div align="center"></div>
<? 

$imgcode = "";
include "src/config.php";
for ($i=0; $i<$symbols; $i++){
$imgcode .= code(mt_rand(0,24))."|";
}

if($code && !$imagetext){

    $error = 1;
    $errstr = "Please Enter the image code";

}elseif($code && $imagetext){


$chart = explode('|', $code);

for ($i=0; $i<5; $i++){
$chart[$i] = decode($chart[$i]);
$chek .= $letter[$chart[$i]];
}
if($chek != strtoupper($_POST['imagetext'])){
    $error = 1;
    $errstr = "You entered incorrect image code";
}elseif($chek == strtoupper($_POST['imagetext'])){
    $error = 1;
    $errstr = "You entered Correct image code. Thank you!";
}


}



if($error) print "<FONT SIZE=4 COLOR=BB0000>$errstr</FONT>";

print <<<FO

<form method="POST">
<table cellpadding="5" cellspacing="1" width="100%">
  <tr>
    <td align="center">Validation</td><input type="hidden" name="code" value="$imgcode">
    <td align="center"><img src="button.php?c=$imgcode" border=0>   <input size=10 type="text" name="imagetext"></td>
  </tr>
  <tr>
    <td align="center" colspan="2">Enter the text above to validate your submission.<BR>
<FONT SIZE=3>'Reload this page if you cant read the above image'</FONT>
</td>
  </tr>
  <tr>
    <td align="center" colspan="2"><input type="submit" name="submit" value="Test Form"></td>
  </tr>
</table>
</form>
FO;

?>





</center>
</body>
</html>

 

I have both scripts working but have no idea how to add the captcha script to the comment script.

Since you don't have the html bit of your comment form posted, I don't think anyone is going to be able to show you specifically where to put each part.

 

Basically, you'll add the php code to your php code and the html code to your html code.

Sorry is it this bit ?

<?php
//create the form to submit comments
//you can add more fields, but make sure you add them to the db table and the page, submitcomment.php
echo "
<a name=\"post\">
<div id=\"submitcomment\" class=\"submitcomment\">
<form name=\"submitcomment\" method=\"post\" action=\"submitcomment.php\" onSubmit=\" return form_Validator(this)\">
<table width=\"100%\">
	<tr>
			<th colspan=\"2\"><h3 class=\"formtitle\">Leave your comment:</h3></th>
	</tr>
	<tr>

			<th scope=\"row\"><p class=\"req\">Name:</p></th>
			<td><input class=\"form\" tabindex=\"1\" id=\"name\" name=\"name\" /></td>
	</tr>
	<tr>
			<th scope=\"row\"><p class=\"opt\">Email:</p></th>
			<td><input class=\"form\" tabindex=\"2\" id=\"email\" name=\"email\" /></td>
	</tr>
	<tr>

	</tr>
	<tr valign=\"top\">
			<th scope=\"row\"><p class=\"req\">Comments:</p><br /></th>
			<td><textarea class=\"formtext\" tabindex=\"4\" id=\"message\" name=\"message\" rows=\"10\" cols=\"40\"></textarea></td>
	</tr>

	<tr>	
			<td> </td>
			<td><input type=\"submit\" name=\"post\" class=\"submit\" value=\"Submit Comment\" /><br />
			<p>Note:<br>All comments are moderated before going live due to spam abuse.
</td>
	</tr>
</table>
<input type=\"hidden\" name=\"tuturl\" value=\"$tuturl\" />
<input type=\"hidden\" name=\"tutid2\" value=\"$tutid2\" />
</form>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.