Jump to content

Recommended Posts

Ok where do i start? Probably by telling you I have very little working knowledge of PHP and that I have been working on this problem for 3 days and have had no luck!

 

Here we go:

 

I have a rate and review script on my site, I am trying to put in a anti spam code. I have tried 5 diffrent scripts including "recaptcha" and always have the same problem. Even if the code entered is wrong it allows you to hit the submit button. It's like the "submit button" and the anti spam picture are not connected in any way. No matter what they enter it allows them to post. I have no idea what to do but I have concluded that im missing something in the starting form field, I just dont know what. I have an anti spam script running right now and i have the same problem. Take a look at the link below and feel free to post and play with it all you like. I have also pasted the form code below. Thank you in advance.

 

http://www.localkaraokeshows.com/countries/canada/mb/bars/fraserwoodhotel/fraserwoodhotelrate.php

 

 

<form method='post'>

<table width='90%' border='1' cellspacing='0' bordercolor=#3a4f6c bgcolor=#f5f9fd>

<tr><b><font size=1>

<td bgcolor=#c2cfdf><b>Add a Review</b></td></tr>

<tr><td><table border='0'cellspacing='0' align=middle bgcolor=#f5f9fd>

<tr><td><font size=1>

Name:      <BR></font></b></td><td><input type='text' maxlength="50" name='name' size=20 style="font-weight:10"></td><td>Rating: <select name=rate><option value="">Select<option value="10">10 (Good)<option value="9">9<option value="8">8<option value="7">7<option value="6">6<option value="5">5<option value="4">4<option value="3">3<option value="2">2<option value="1">1 (Bad)</select></td></tr></table><table>

<tr valign='top'><td></td><td align=middle>

<?php

smile();

?></td><tr><td><font size=1>

Comment:<BR></b></td>

<td><textarea cols='35' rows='3' name='comment' onkeydown=textCounter(this.form.comment,this.form.descriptionleft,400); onkeyup=textCounter(this.form.comment,this.form.descriptionleft,400);></textarea><br>Characters Left <INPUT maxLength=3 name=descriptionleft readOnly size=3 tabIndex=400 value=400 style='BORDER-RIGHT: 0px; BORDER-TOP:0px;BORDER-LEFT:0px; BORDER-BOTTOM:0px;BACKGROUND-COLOR: #f5f9fd;'></td></tr>

<tr><td></td><td>

 

<img src="antispam.php"><br>

<input name="anti_spam_code"><br>

 

<input type="submit" value="Add Review" style="background:#f5f9fd;border-width:1;Border-color:#3a4f6c;" />

 

<?php

@session_start(); // start session if not started yet

if ($_SESSION['AntiSpamImage'] != $_REQUEST['anti_spam_code']) {

  // set antispam string to something random, in order to avoid reusing it once again

  $_SESSION['AntiSpamImage'] = rand(1,9999999);

 

  // here you add code to let user know incorrect code entered

 

}

else {

  // set antispam string to something random, in order to avoid reusing it once again

  $_SESSION['AntiSpamImage'] = rand(1,9999999);

  exit;

  // everything is fine, proceed with processing feedback/comment/etc.

 

 

}

?>

 

 

</td></tr>

</table>

</table>

</form>

Link to comment
https://forums.phpfreaks.com/topic/179390-solved-anti-spam-code-problems/
Share on other sites

This is what i get...

 

Warning: Cannot modify header information - headers already sent by (output started at /home/content/y/i/p/yippydoo/html/karaoke/countries/canada/mb/bars/fraserwoodhotel/fraserwoodhotelrate.php:13) in /home/content/y/i/p/yippydoo/html/karaoke/countries/canada/mb/bars/fraserwoodhotel/review.php on line 205

 

I placed the code at the very top before everything else, same error. Is it possible I have it in the wrong document? does it go in the same doc as the one with the code to make it display? If so, I'm open to ideas, if not which doc should it be in?

 

Thanks

Now I get this:

 

Fatal error: Call to undefined function: smile() in /home/content/y/i/p/yippydoo/html/karaoke/countries/canada/mb/bars/fraserwoodhotel/274670.php on line 33

 

Take A look:

 

 

http://www.localkaraokeshows.com/countries/canada/mb/bars/fraserwoodhotel/274670.php

Sorry about the above post, took me a bit to realize it was just a part of the code and not an html page. Thats what i get for coping and pasting without reading. I added your code into the proper places in the original page and now im getting:

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/content/y/i/p/yippydoo/html/karaoke/countries/canada/mb/bars/fraserwoodhotel/fraserwoodhotelrate.php:13) in /home/content/y/i/p/yippydoo/html/karaoke/countries/canada/mb/bars/fraserwoodhotel/review.php on line 2

 

Here is the link again if you need it. Thanks

 

http://www.localkaraokeshows.com/countries/canada/mb/bars/fraserwoodhotel/fraserwoodhotelrate.php

 

if you put the script at the top of the file, with nothing above it, it is quite possible that you are working in UTF-8 with BOM.

 

The BOM causes this kind of errors.

 

When working with PHP you should work in UTF-8 without BOM.

 

(...) in PHP, if output buffering is disabled, it has the subtle effect of causing the page to start being sent to the browser, preventing custom headers from being specified by the PHP script. The UTF-8 representation of the BOM is the byte sequence EF BB BF, which appears as the ISO-8859-1 characters  in most text editors and web browsers not prepared to handle UTF-8.

http://en.wikipedia.org/wiki/Byte-order_mark

"Can you just add the file 274670.php, without any changes (just for testing)"

 

Here you go,

 

http://www.localkaraokeshows.com/countries/canada/mb/bars/fraserwoodhotel/274670.php

 

Can someone please tell me in simple terms what the post above means? I don't understand the aberviations.

Interesting, so now the test page you gave me appears to be working, however when I past the code into my rate and review page i get this again. And it still allows the entry if the code is wrong?

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/content/y/i/p/yippydoo/html/karaoke/countries/canada/mb/bars/fraserwoodhotel/fraserwoodhotelrate.php:13) in /home/content/y/i/p/yippydoo/html/karaoke/countries/canada/mb/bars/fraserwoodhotel/review.php on line 2

 

I will get that to you ASAP, Does anyone know how to attach a file to a pm in here? I tried and dont see a button for it.

 

I don't suppose anyone has a diffrent Rate and Review script with anti bot that would be easier to use than this one? I'm not attached in any way to this one, as a matter of fact I dont really like it but it's the only one i found that didnt want a fortune to buy it.

is it possible to attach fraserwoodhotelrate.php or PM me it (as a file) ?

 

Ok got it thanks, I'm posting these files publicly in a zip file so anyone can take a look if they want. One again, thank you everyone for helping me out especially Madtechie. At the moment I still have the same problem as stated in the first post. oops uploaded it twice lol

 

[attachment deleted by admin]

Okay the reason for the error is this

While the code is at the top of the file, its not before any output..

 

as your calling the file like this

<center>

<?php include "review.php"; ?>

</center>

So anything that if outputted before the include is still output.. thus causing the error.

 

if you move

<?php
session_start(); // start session if not started yet
$ERROR = "";
if(isset($_REQUEST['anti_spam_code']))
{
if ($_SESSION['AntiSpamImage'] != $_REQUEST['anti_spam_code']) {
  // set antispam string to something random, in order to avoid reusing it once again
  $_SESSION['AntiSpamImage'] = rand(1,9999999);
  $ERROR = "WRONG CODE";
}else {
  // set antispam string to something random, in order to avoid reusing it once again
  $_SESSION['AntiSpamImage'] = rand(1,9999999);
  // everything is fine, proceed with processing feedback/comment/etc.
  
  //PROCESS POST
  /*
  	SQL stuff for adding new comment etc
  */
  header("Location: fraserwoodhotelrate.php"); //jump to new page
  exit();
}
}
?>

from review.php to the TOP of fraserwoodhotelrate.php if should be fine

I tried that and it does get rid of th error but it still allows a post if the entry is wrong. It's like the anti bot and rate and review are not connected. give me 5 min and take a look I will make those changes right now. then visit the web page and enter a review and the wrong code and see what I mean.

 

Changes are done

 

Thanks Jeremy

 

http://www.localkaraokeshows.com/countries/canada/mb/bars/fraserwoodhotel/fraserwoodhotelrate.php

Your right its not linked.. no offence but the code really needs to be re-written,

I have got it working, but I still think it need re-doing, as theirs tons of issues, and it would be probably quicker to start over.. (no offence intended, as i believe you picked this up from another site)

See zip attached

 

[attachment deleted by admin]

Your right its not linked.. no offence but the code really needs to be re-written,

I have got it working, but I still think it need re-doing, as theirs tons of issues, and it would be probably quicker to start over.. (no offence intended, as i believe you picked this up from another site)

See zip attached

 

No offence taken my friend since the script it's self looks crappy. I really wanted a nicer looking one but there are hardly any Rate and REview scripts out there that they dont want a fortune for. Thanks for all the help I'll make the changes right now. Do you happen to know of any other rate and review scripts that are better than this one?

I removed the redirect and added the error check to this line

if (strlen($name)>=1 && strlen($comment)>=1 && strlen($rate)>=1 && $stats[4]!=$ip && empty($ERROR)){

 

as it validated the comment and rate but you also needed it to fail if the captcha was invalid

note:

&& empty($ERROR)

 

So now when the captcha is invalid, the error gets set

$ERROR = "WRONG CODE";

then will fail on the write to file check

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.