patentu Posted September 21, 2011 Share Posted September 21, 2011 i have an html page with 3 fields "name,email,message" this goes to done.php done.php process the data and saves "name,email,message,ip" to an .txt file on the server,(IIS6 server 2003)how can i redirect to another page if that IP submitted already?Because i have some "friends" who refreshes the page and i get allot of empty fields hope you understand. Quote Link to comment https://forums.phpfreaks.com/topic/247590-banningredirect-after-submission/ Share on other sites More sharing options...
brentman Posted September 21, 2011 Share Posted September 21, 2011 Can you put this on your page: header( 'Location: http://www.yoursite.com/new_page.html' ); Just dont have any outputs to the browser before this or it won't work for sure... Quote Link to comment https://forums.phpfreaks.com/topic/247590-banningredirect-after-submission/#findComment-1271411 Share on other sites More sharing options...
patentu Posted September 21, 2011 Author Share Posted September 21, 2011 i have that in the php and works,i want a script that will check if that ip already submited that form,if yes redirect to other url without saving anything on the server. Quote Link to comment https://forums.phpfreaks.com/topic/247590-banningredirect-after-submission/#findComment-1271415 Share on other sites More sharing options...
Muddy_Funster Posted September 21, 2011 Share Posted September 21, 2011 risky thing to play with in this climate of dynamicly assigned IP addresses and the such. are you focusing purely on IPv4 or are you accomidating the IPv6 market as well? Quote Link to comment https://forums.phpfreaks.com/topic/247590-banningredirect-after-submission/#findComment-1271418 Share on other sites More sharing options...
patentu Posted September 21, 2011 Author Share Posted September 21, 2011 <? $visitor = $_SERVER['REMOTE_ADDR']; if (preg_match("/192.168.0.1/",$visitor)) { header('Location: http://www.yoursite.com/thank-you.html'); } else { header('Location: http://www.yoursite.com/home-page.html'); }; ?> something like this,but i want it to take the ip from a list Quote Link to comment https://forums.phpfreaks.com/topic/247590-banningredirect-after-submission/#findComment-1271420 Share on other sites More sharing options...
sphinx Posted September 21, 2011 Share Posted September 21, 2011 Why don't you just add captcha? Or add field checkers. Quote Link to comment https://forums.phpfreaks.com/topic/247590-banningredirect-after-submission/#findComment-1271433 Share on other sites More sharing options...
sphinx Posted September 21, 2011 Share Posted September 21, 2011 // for your case, example 2 "field2" would be an email field. //"field4" would be captcha. if(isset($_POST['submit'])) { $field1 = $_POST['field1']; $field2 = $_POST['field2']; $field3 = $_POST['field3']; if(empty($field1)|| empty($field2)|| empty($field3)) { $errors .= "\n Some of the above fields have not been filled in."; } //Injection not nessessary but recommended to avoid idiots. if(IsInjected($field2)) { $errors .= "\n That email is not valid."; } if(empty($_SESSION['field4'] ) || strcasecmp($_SESSION['field4'], $_POST['field4']) != 0) { $errors .= "\n Those three characters entered are incorrect. Please try again, alternatively click <a href='javascript:refreshCaptcha();'>here</a> to refresh the characters."; } //start of injection function IsInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } Remove the captcha part if you don't want it incorporated. Quote Link to comment https://forums.phpfreaks.com/topic/247590-banningredirect-after-submission/#findComment-1271434 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.