Click here to Skip to main content
15,900,713 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Here is the code:
XML
<form name=Agreement method=get action=#>
<td><input type="radio" id="examtype" name="examtype" value="agree" /> : I agree!<br />
<td><input type="radio" id="examtype" name="examtype" value="disagree" /> : I disagree!<br />
<input type="submit" name="Chat" value="Let's Chat!" onclick="return validateForm();" />

<script>
function validateForm(){
var checked = null;
var inputs = document.getElementsByName('examtype');
for (var i = 0; i < inputs.length; i++) {
          if (inputs[i].checked) {
           checked = inputs[i];
   }
}
if(checked==null)
{
    alert('Please choose an option');
}
if(checked.value=="agree"){
    var a=confirm('You have chosen to '+checked.value+' with the rules is this correct?')
if(a){alert("You will now be redirected to the chat page!");}
else{alert("Please agree to the rules as disagreeing to them leaves you permanently banned from our site!")
;}}
else if(checked.value=="disagree"){
    var d=confirm('You have chosen to '+checked.value+' with the rules is this correct?');
if(d){alert("You will now be permanently banned from this site!");
}}
else if(checked==null)
{
    alert('Please choose an option');
    return false;
}}
</script>

What I would like is for it to write to my .htaccess file "deny from The Persons IP address who disagreed to rules"
Posted
Comments
Sergey Alexandrovich Kryukov 25-Nov-13 15:55pm    
Why?! .htaccess is supposed to be a static file. If you want to add some functionality based on modification on this file, this is a good indication of a wrong approach, a possible technology abuse.
In all cases, there is nothing to discuss unless you explain your goals.
—SA

Quite a big nonsense. You can't do and you should not do that.

1) First of all, how do you want to identify the user who has not accepted the agreement? By IP? Well, what if he is using DHCP? Several hours later he will have an other IP - and you will probably block somebody else. And at the end you will end up with hundreds of blacklisted IPs.

2) You should not modify htaccess file from php, and you can not do that from javascript (if you could, than it would have no use at all)

But you could do it using a cookie, but better use some form of authentication too.
 
Share this answer
 
2 files required 1 with: "
XML
If you disagree to the rules it <b>will</b> lead to an immediate <b>permanent ban!!!</b><br/>
<td><input type="radio" id="agreement" name="agreement" value="agree" /> : I agree!<br/>
<td><input type="radio" id="agreement" name="agreement" value="disagree" /> : I disagree!<br/>
<input type="submit" name="Chat" value="Let's Chat!" onclick="return validateForm();" />

<script>
function validateForm(){
var myip = '<%= Request.UserHostAddress %>';
var checked = null;
var inputs = document.getElementsByName('agreement');
for (var i = 0; i < inputs.length; i++) {
          if (inputs[i].checked) {
           checked = inputs[i];
   }
}
if(checked==null)
{
    alert('Please choose an option');
}
if(checked.value=="agree"){
    var a=confirm('You have chosen to '+checked.value+' with the rules is this correct?')
if(a){alert("You will now be redirected to the chat page!");
window.location.assign("http://3dsemolga.3owl.com/chat/");}
else{alert("Please agree to the rules as disagreeing to them leaves you permanently banned from our site!")
;
}}
else if(checked.value=="disagree"){var a=confirm('You have chosen to '+checked.value+' with the rules is this correct?')
if(a){alert("You will now be permanently banned from this site!");
window.location.assign("http://3dsemolga.3owl.com/disagree.php");
}}
else if(checked==null)
{
    alert('Please choose an option');
    return false;
}}
</script>
"







and another with:

"
PHP
<?php

  $file = $_SERVER['DOCUMENT_ROOT'] .'/.htaccess';

  $fp = fopen($file, 'a+');

  fwrite($fp, "deny from $_SERVER[REMOTE_ADDR]\n");

  fclose($fp);

?>
"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900