Hello..

I need some help from the pros.

lately I've been getting alot of spam on my site's contact forms.

I want to add IP request in my forms so I can block the spammer's IPs.

So far I have got the job 50% done.

On my site i have 2 contact forms.

the first one is the main CONTACT US form.
the second one is the feedback form.

I've got it working on the main form.
I added

$ip=@$_SERVER['REMOTE_ADDR'];

to my mail.php page and I added

<input type="hidden" name="IP Address" value="<?php echo $_SERVER['REMOTE_ADDR'] ?>">

to my contact page where the form is.
changed changed contact.html to contact.php and its working good.

the problem is with the feedback form.

unlike the main contact form that uses tables, the feedback form is a sliding type and is written with DIVs and uses java, css and jquery to function.

i tried adding the same code shown above to this form the same way I did with the main form, but it doesn't work.

your help will be greatly appreciated.

thanks in advance

instead of this i would suggest u to use captcha to stop spamming in ur site...if u need help for that i m always ready to help others....
their are a lot of ways to stop bots from spamming.....
1. Using Captcha-although popular and most widely used in which we convert text into image and then use it for verification.....but now advanced bots are using OCR(optical character Reader)to detect characters from the image...
Still it provides a bit of security....
2. Hidden form field - I leave this blank and call it something like "zipcode" which will hopefully encourage spambots to fill it in, then I reject the submission if this comes through as anything other than an empty string. I find that using a true hidden field (rather than a non-visible text field) prevents form completition software from filling it in. This may only be effective against the most basic spambots but it's worth putting in place anyway.

3. Check referrer - When processing the form I make sure that it was submitted from the relevant page on my own website. This stops spambots that post directly to the website's processing page.

4. Check time - I put a hidden field in the form containing the current timestamp then when processing the form I can compare the time the form was created to the time it was submitted. I assume that spambots complete forms instanteously so if the difference is less than 5 seconds I reject it as spam.

5. Check form content - If I don't expect HTML content to appear in any/all of the form fields I check each posted value for HTML tags and reject the submission as spam if any are found. In my experience a lot of spammers submit HTML code.

Hope this will help u.....

a few of the spam or junk mail that I'm getting is actual people writing useless garbage..

I will use captcha, but I also want to get this IP request working so I can block these individuals..

can anyone please help me?

thanks

I guess either nobody knows how to do this or nobody wants to help.. :(

i can only workout on ur problem after 1 day...busy in college stuff....n it's aesy i can do it....just give me a day.....

so here is what i came out with to solve ur problem:

<?php

   $ip = $_SERVER['REMOTE_ADDR'];//to get ip of the user

   if($ip == "127.0.0.1"){
      echo "<font color='red'>Ooops, your ip address has been banned from this website.</font>";
      exit();
   }

 ?>

instead of using if statement every time i would suggest u another way....

<?php
$banned[0]="127.0.0.1"; // IP in the form of "127.0.0.1" or whatever
//$banned[1]="yyy.yyy.yyy.yyy";
//$banned[2]="zzz.zzz.zzz.zzz";
// add as many as you wish
echo in_array($_SERVER['REMOTE_ADDR'],$banned);
if (in_array($_SERVER['REMOTE_ADDR'],$banned)) 
echo "<font color='red'>Ooops, your ip address has been banned from this website.</font>";

Hope this is useful...
if u have doubt then u can PM me....
if it's clear mark thread as solved....

hey..

i have

$ip = $_SERVER['REMOTE_ADDR']

in my mail.php

this is how my form is setup in my index.php but doesn't work..

please let me know what i've done wrong.

<div class="container">
    	<div id="contactFormContainer">
      		<div id="contactForm">
        		<div class="loader"></div>
					<div class="bar"></div>
            <form action="http://www.gamersparadise.ca/FormToEmail3.php" class="contactForm" name="cform" method="post">
            
                <div class="input_boxes">
                    <p><label for="name">Name:</label><span class="name-missing">Please enter your name</span><br />
                    <input id="name" type="text" value="" name="name" /></p>
					<p><label for="e-mail">E-mail:</label><span class="email-missing">Please enter a valid e-mail</span><br />

			<input id="ip" type="hidden" name="IP Address" value="<?php echo $_SERVER['REMOTE_ADDR'] ?>">

                    <input id="e-mail" type="text" value="" name="email" /></p>
					<div><input type="hidden" name="IP Address" value="<?php echo $_SERVER['REMOTE_ADDR'] ?>"></div>
					<p><label for="message">Message:</label><span class="message-missing">Say something!</span><br />
                    <textarea id="message" rows="" cols="" name="message"></textarea></p>
              </div>   
			  
			  
              <input class="submit" type="submit" name="submit" value="Submit" onfocus="this.blur()"  />
        </form>
      </div>
      <div class="contact"></div>    
  </div>
</div>
<div id="backgroundPopup"></div>

thanks

means it is not showing user's ip?????or what is the problem specify....
just echo it and see is it displaying ip or not....
moreover their is an advanced version of this one....i will tell u if it doesn't work...although the code i used worked fine for me....

hey..

yeah.. the ip is not showing up..

it works in the other form but not this one.

this is the code for the other form which the ip request works.

<table width="100%" height="344" style="border: 0px solid #000000; margin: 0; padding: 0; background-color: #FFFFFF; font-weight: bold;"><tr><td height="338">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr bgcolor="#FFFFFF">
<td width="32%"><font color="#000000" size="3" face="Georgia"><b> E-mail Address:<font color="#FF0000"> *</font></b></font></td>
<td width="68%"><input name="email" type="text" id="email" size="43" maxlength="100" /></td></tr>
<tr bgcolor="#FFFFFF">

<input type="hidden" name="IP Address" value="<?php echo $_SERVER['REMOTE_ADDR'] ?>">


<td><font color="#000000" size="3" face="Georgia"><b>Name:<font color="#FF0000"> *</font></b></font></td>
<td><font color="#000000" size="3" face="Georgia"><input name="Name" type="text" id="Name" value="" size="43" maxlength="" /></font></td></tr>
<tr bgcolor="#FFFFFF">
<tD><font color="#000000" size="3" face="Georgia"><b>Phone Number:<font color="#FF0000"> *</font></b></font></td>
<td><font color="#000000" size="3" face="Georgia"><input name="Phone Number" type="text" id="Phone Number" value="" size="43" maxlength="" /></font></td></tr>
<tr bgcolor="#FFFFFF">
<td><font color="#000000" size="3" face="Georgia"><b> Subject:<font color="#FF0000"> *</font></b></font></td>
<td><input name="subject" type="text" id="subject" size="43" maxlength="100" /></td></tr>
<tr bgcolor="#FFFFFF">
<td height="141"><font color="#000000" size="3" face="Georgia"><b>Message:<font color="#FF0000"> *</font></b></font></td>
<td><font color="#000000" size="3" face="Georgia"><textarea name="Message" cols="55" rows="8" id="Message" ></textarea></font>
</td></tr>
<tr><td align="left"><font color="#FF0000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>*</b></font> <font size="1" face="Verdana, Arial, Helvetica, sans-serif">Required</font></td>
  <td align="left"><br />    
 
  <input name="" type="submit" onclick="MM_validateForm('email','','RisEmail','Name','','R','Phone Number','','R','subject','','R','Message','','R');return document.MM_returnValue" value="Submit" /></td>
</tr>
<tr></tr>
</table></td></tr></table></form></td>

  
  </tr>
</table>

thanks..