Jump to content

Recommended Posts

No

 

you need to add the code just after you //Content has value

 

<?php
if(isset($_POST['content'])) { //Page was submitted
    if (!$_POST['content']) { //value of content is empty
        $output = "There was no data entered!";
        echo $output;
    } else { //Content has value
        echo "<input name='temp' type='hidden' value='$temp' />";
        if(($_POST['temp'] != $_SESSION['tmp1']) )
        {
        //the block in Content has value goes here
        	//Content has value
                $content = $_POST['content'];
                $info = $_POST['info'];    

                $content = language_filter($content); 

                @$fp = fopen("project4.txt", "a");
                fwrite($fp, $content."\r\n");
                $info = file('project4.txt');
                for ($i = 0; $i < count($info); $i++) {
                   echo '<br><hr>';
                   echo nl2br(htmlentities(stripslashes(trim($info[$i])),ENT_QUOTES));
                }
                fclose($fp);
            }
        }
        $_SESSION['tmp1'] = $_POST['temp'];

?>

 

*untested

This is the code.

 

<form method="POST">
<table border="1" align="center" width="300">
  <tr>
    <td colspan="2" align="center">How to Change the World?</td>
  </tr>
  <tr>
    <td align="center"><img src="../images/atlas.jpg" width="100" height="165" /></td>
    <td><textarea name = "content" cols="50" rows="10"></textarea></td>
  </tr>
  <tr>
    <td colspan="2">
<?php

function language_filter($string) { 
   $obscenities = array("curse","word"," foul ","language"); 
    foreach ($obscenities as $curse_word) { 
        if (stristr(trim($string),$curse_word)) { 
            $length = strlen($curse_word); 
            for ($i = 1; $i <= $length; $i++) { 
                $stars .= "*"; 
            } 
            $string = eregi_replace($curse_word,$stars,trim($string)); 
            $stars = ""; 
        } 
    } 
    return $string; 
} 

if(isset($_POST['content'])) { //Page was submitted
    if (!$_POST['content']) { //value of content is empty
        $output = "There was no data entered!";
	echo $output;

    } else { //Content has value
        $content = $_POST['content'];
        $info = $_POST['info'];    

        $content = language_filter($content); 

        @$fp = fopen("project4.txt", "a");
        fwrite($fp, $content."\r\n");
        $info = file('project4.txt');
        for ($i = 0; $i < count($info); $i++) {
           echo '<br><hr>';
           echo nl2br(htmlentities(stripslashes(trim($info[$i])),ENT_QUOTES));
        }
        fclose($fp);
    }
}
?>
</td>
  </tr>
  <tr>
    <td colspan="2" align="center"><input type = submit name="submit"></td>
  </tr>
</table>
</form>

try this :

 

<?php
function language_filter($string) { 
   $obscenities = array("curse","word"," foul ","language"); 
    foreach ($obscenities as $curse_word) { 
        if (stristr(trim($string),$curse_word)) { 
            $length = strlen($curse_word); 
            for ($i = 1; $i <= $length; $i++) { 
                $stars .= "*"; 
            } 
            $string = eregi_replace($curse_word,$stars,trim($string)); 
            $stars = ""; 
        } 
    } 
    return $string; 
}

if(isset($_POST['content'])) { //Page was submitted
    if (!$_POST['content']) { //value of content is empty
echo 'There was no data entered!';
} else { //Content has value
        $info = $_POST['info'];    
        $content = language_filter($_POST['content']); 
        @$fp = fopen("project4.txt", "a");
        fwrite($fp, $content."\r\n");
	fclose($fp);
	$_SESSION['posted'] = TRUE;
	header( "Location: " .$_SERVER['PHP_SELF'] );
        $info = file('project4.txt');
        for ($i = 0; $i < count($info); $i++) {
           echo '<br><hr>';
           echo nl2br(htmlentities(stripslashes(trim($info[$i])),ENT_QUOTES));
        }
        fclose($fp);
    }
} 

?>

<form method="POST">
<table border="1" align="center" width="300">
  <tr>
    <td colspan="2" align="center">How to Change the World?</td>
  </tr>
  <tr>
    <td align="center"><img src="../images/atlas.jpg" width="100" height="165" /></td>
    <td><textarea name = "content" cols="50" rows="10"></textarea></td>
  </tr>
  <tr>
    <td colspan="2">
<?php
	if($_SESSION['posted']) {
        @$fp = fopen("project4.txt", "a");
        $info = file('project4.txt');
        for ($i = 0; $i < count($info); $i++) {
           echo '<br><hr>';
           echo nl2br(htmlentities(stripslashes(trim($info[$i])),ENT_QUOTES));
        }
        fclose($fp);
	}
?>



</td>
  </tr>
  <tr>
    <td colspan="2" align="center"><input type = submit name="submit"></td>
  </tr>
</table>
</form>

*untested

<?php
session_start();
function language_filter($string) { 
   $obscenities = array("curse","word"," foul ","language"); 
    foreach ($obscenities as $curse_word) { 
        if (stristr(trim($string),$curse_word)) { 
            $length = strlen($curse_word); 
            for ($i = 1; $i <= $length; $i++) { 
                $stars .= "*"; 
            } 
            $string = eregi_replace($curse_word,$stars,trim($string)); 
            $stars = ""; 
        } 
    } 
    return $string; 
}

if(isset($_POST['content'])) { //Page was submitted
    if (!$_POST['content']) { //value of content is empty
echo 'There was no data entered!';
} else { //Content has value
        $info = $_POST['info'];    
        $content = language_filter($_POST['content']); 
        $fp = fopen("project4.txt", "a");
        fwrite($fp, $content."\r\n");
	fclose($fp);
	$_SESSION = 'isset';
	header( "Location: " .$_SERVER['PHP_SELF'] );
    }
} 

?>

<form method="POST">
<table border="1" align="center" width="300">
  <tr>
    <td colspan="2" align="center">How to Change the World?</td>
  </tr>
  <tr>
    <td align="center"><img src="../images/atlas.jpg" width="100" height="165" /></td>
    <td><textarea name = "content" cols="50" rows="10"></textarea></td>
  </tr>
  <tr>
    <td colspan="2">
<?php

	if(isset($_SESSION)) {
	echo 'Form was posted';
        $fp = fopen("project4.txt", "a");
        $info = file('project4.txt');
        for ($i = 0; $i < count($info); $i++) {
           echo '<br><hr>';
           echo nl2br(htmlentities(stripslashes(trim($info[$i])),ENT_QUOTES));
        }
        fclose($fp);
	unset($_SESSION);
	}
?>



</td>
  </tr>
  <tr>
    <td colspan="2" align="center"><input type = submit name="submit"></td>
  </tr>
</table>
</form>

*tested

Could someone please explain the code that was

inserted into my code?

 

<?php
session_start(); //Explain
$_SESSION = 'isset';//Explain
header( "Location: " .$_SERVER['PHP_SELF'] );//Explain

if(isset($_SESSION)) {//Explain
echo 'Form was posted';
$fp = fopen("project4.txt", "a");
$info = file('project4.txt');
for ($i = 0; $i < count($info); $i++) {
      echo '<br><hr>';
      echo nl2br(htmlentities(stripslashes(trim($info[$i])),ENT_QUOTES));
}
fclose($fp);
unset($_SESSION);//Explain
}
?>

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.