adamriley Posted May 11, 2010 Share Posted May 11, 2010 Submit.php ----------------------------------------------------- <?php // error_reporting(E_ALL); // echo '<pre>$_GET:' . print_r($_GET,true) . '</pre>'; // echo '<pre>$_SERVER:' . print_r($_SERVER,true) . '</pre>'; // echo $_SERVER['REQUEST_METHOD']; if(function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get")) @date_default_timezone_set(@date_default_timezone_get()); // session_start(); // check to make sure there is a session if(!isset($_SESSION['dir'])){ echo "Please contact webmaster as soon as posible"; die(); } else { } // $Sware_words = <<<Words Require("includes/bad_word_list.txt"); Words; $Name = $_POST['Name']; // get the name from the form $Email = $_POST['Email']; // get the email from the form $code = $_POST['Code']; // Get the secrity code $dir = $_SESSION['dir']; // Get who they have picked $file = $_SESSION['dir']; // Get the dir // $Time = date('h.i.s A'); // get the time // $Date = date('l jS \of F Y'); // get the date // // check the name to witheld it from the front person if ($Name = "Pleasae Enter your full name"){ $Name = "**********"; } else { } // // // Check That the name has not got no sware words in it if ($Name = $Sware_words){ unset($_SESSION['dir']); // write the normal info into the Blocked list $Blockfile = fopen("Blocked.txt","a+"); fwrite($Blockfile, "\r\n$Email:$code:$Date:$Time"); die(); } else { } $pfile = fopen("places/$dir.txt","w"); fwrite($pfile, "\r\n$Name:$Email:$code:$Date:$Time"); header('Location: http://localhost/Game/red.php?$dir'); // ?> Could any one tell me why the if statement returns when the $name is not one of the sware words ?? if ($Name = $Sware_words){ unset($_SESSION['dir']); // write the normal info into the Blocked list $Blockfile = fopen("Blocked.txt","a+"); fwrite($Blockfile, "\r\n$Email:$code:$Date:$Time"); die(); } else { } Link to comment https://forums.phpfreaks.com/topic/201403-php-help-script/ Share on other sites More sharing options...
kenrbnsn Posted May 11, 2010 Share Posted May 11, 2010 You need to use "==" in if statement: <?php if ($Name == $Sware_words) ?> One "=" is for assignment, two "==" for comparison. Ken Link to comment https://forums.phpfreaks.com/topic/201403-php-help-script/#findComment-1056721 Share on other sites More sharing options...
adamriley Posted May 12, 2010 Author Share Posted May 12, 2010 This is the up to date file but still , I used the "==" and the if statement does not return even though that the $name is a sware word listed in the "Bad_words_list.txt" what im thinking is that you cannot Require the file so theres nothing for it to check ??? <?php error_reporting(E_ALL); if(function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get")) @date_default_timezone_set(@date_default_timezone_get()); // session_start(); // check to make sure there is a session if(!isset($_SESSION['dir'])){ echo "Please contact webmaster as soon as posible"; die(); } else { } $Name = $_POST['Name']; $Email = $_POST['Email']; $code = $_POST['Code']; $dir = $_SESSION['dir']; $file = $_SESSION['dir']; // // Automatic detection dissabled due to not beeing coded fully /* $file = <<<Words Require("includes/bad_word_list.txt"); Words; */ // $Time = date('h.i.s A'); // get the time // $Date = date('l jS \of F Y'); // get the date // // check the name to witheld it from the front person if ($Name == "Please Enter your full name"){ $Name = "**********"; } else { } // // // Check That the name has not got no sware words in it /* if ($Name == $file){ // unset($_SESSION['dir']); // write the normal info into the Blocked list $Blockfile = fopen("Blocked.txt","a+"); fwrite($Blockfile, "\r\n$Email:$code:$Date:$Time"); echo "Please contact webmaster due to bad name being detected with you security code you got from the last stage" die(); } else { } */ $pfile = fopen("places/$dir.txt","w"); fwrite($pfile, "\r\n$Name:$Email:$code:$Date:$Time"); header('Location: http://localhost/Game/red.php?$dir'); // ?> Link to comment https://forums.phpfreaks.com/topic/201403-php-help-script/#findComment-1057367 Share on other sites More sharing options...
adamriley Posted May 12, 2010 Author Share Posted May 12, 2010 Bumpy any one at the other end ? Link to comment https://forums.phpfreaks.com/topic/201403-php-help-script/#findComment-1057392 Share on other sites More sharing options...
adamriley Posted May 13, 2010 Author Share Posted May 13, 2010 Any one care to answer Link to comment https://forums.phpfreaks.com/topic/201403-php-help-script/#findComment-1057744 Share on other sites More sharing options...
kenrbnsn Posted May 13, 2010 Share Posted May 13, 2010 The problem is the way you're creating the variable $Sware_words: <?php $Sware_words = <<<Words Require("includes/bad_word_list.txt"); Words; ?> All that does is put the string 'Require("includes/bad_word_list.txt");' in the variable. What does the text file look like? One word per line? If so, do something like this: <?php $Sware_words = array_map('trim',file('includes/bad_word_list.txt')); if (in_array($Name, $Sware_words)) { // // etc... // } ?> Ken Link to comment https://forums.phpfreaks.com/topic/201403-php-help-script/#findComment-1057750 Share on other sites More sharing options...
adamriley Posted May 13, 2010 Author Share Posted May 13, 2010 Thanks very much for your reply Link to comment https://forums.phpfreaks.com/topic/201403-php-help-script/#findComment-1057944 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.