-2

i am very new with html/css too with php and my English is very poor.. so , my problem ... , i have this Codec from here . I have Three File , the First is index.php

<html> 
<head> 
<link rel="stylesheet" href="style.css" type="text/css"> 
</head> 

<body> 
<form action="" method="POST"> 
<label>Name: 
<input type="text" name="Name" class="Input" style="width: 225px" required> 
</label> 
<br><br> 
<label> Comment: <br> 
<textarea name="Comment" class="Input" style="width: 300px" required> </textarea> 
</label> 
<br><br> 
<input type="submit" name="Submit" value="Submit Comment" class="Submit"> 
</form> 
</body> 
</html> 

<?php 

    if($_POST['Submit']){  



        $Name = $_POST['Name']; 
        $Comment = $_POST['Comment']; 


        #Get old comments 
        $old = fopen("comments.txt", "r+"); 
        $old_comments = fread($old, 1024); 


        #Delete everything, write down new and old comments 
        $write = fopen("comments.txt", "w+"); 
        $string = "<b>".$Name."</b><br>".$Comment."<br>\n".$old_comments; 
        fwrite($write, $string); 
        fclose($write); 
        fclose($old); 
    } 

        #Read comments 
        $read = fopen("comments.txt", "r+"); 
        echo "<br><br>Comments<hr>".fread($read, 1024); 
        fclose($read); 


?>

Than a style.css File and a empty with the name comments.txt . This Files i have to a Computer (computer A) , with apache , start it with , /etc/init.d/apache2 restart .In another Computer (computer B) i write to Browser, 192.345.345.100/index.php , in Name i write my name and in Comment , a comment.. ,what come nothing.... .Image from mine Browser enter image description here , can please anyone help me , Thanks !

The image from Computer B , in Browser write http://192.345.345.100/info.php ,info.php which i have to build with <?php phpinfo(); ?> .

See stacktrace:

enter image description here

3edf1w
  • 105
  • 2
  • 9
  • I've never seen the `t` option for `fopen`. I'd just use `file_get_contents` and `file_put_contents`. They are much easier. A DB would be a better approach though. – user3783243 Jun 22 '18 at 16:26
  • The image looks like you don't have PHP installed. – user3783243 Jun 22 '18 at 16:27
  • 1
    Possible duplicate of [PHP code is not being executed, instead code shows on the page](https://stackoverflow.com/questions/5121495/php-code-is-not-being-executed-instead-code-shows-on-the-page) – user3783243 Jun 22 '18 at 16:28
  • Thanks for your answer! , sorry but i am very new , i don't understand with file_get_contents , can you please give me a example .... – 3edf1w Jun 22 '18 at 16:30
  • 2
    php.net is a great place to go for answers http://php.net/manual/en/function.file-get-contents.php and http://php.net/manual/en/function.file-put-contents.php Those will be for after you get the PHP running. They will replace your `fopen`, `fread`, `fwrite`, and `fclose`. – user3783243 Jun 22 '18 at 16:31
  • From my computer A, PHP -V : PHP 7.2.2-1 (cli) (built: Feb 1 2018 15:19:04) ( NTS ) – 3edf1w Jun 22 '18 at 17:05
  • That is command line. Do you have if configured to run from your server software as well? – user3783243 Jun 22 '18 at 18:00
  • /etc/init.d/apache2 restart – 3edf1w Jun 22 '18 at 18:14
  • That just restarts apache, do you have the module installed? – user3783243 Jun 22 '18 at 18:15
  • which module ?? – 3edf1w Jun 22 '18 at 18:27
  • PHP you need apache to know to run PHP. – user3783243 Jun 22 '18 at 20:13
  • i know .. so every time before server to use , i start apache... /etc/init.d/apache2 restart – 3edf1w Jun 22 '18 at 20:45
  • @user3783243 ,You have Right , T don't belong to fopen.... i will to revise from mine Code.... but it have not affect to display.... – 3edf1w Jun 23 '18 at 17:18

1 Answers1

0

Edit new my comment... , i had two problem because PHP not display.... . First ,me messing some modules for PHP , libapache2-mod-php7.0..

Seconds ,i not had access right to my Website... , with sudo chown -R www-data:www-data /var/www/html , i have this Right to give.... image how the Website see with the Comments , The Code remain identical...

@user3783243 , today i to red this , how Understand , t convert \n to \r\n , it is ONLY for Windows user.. , Linux ignored it ... .

\n is used for Unix systems (including Linux, and OSX).

\r\n is mainly used on Windows.

\r is used on really old Macs.

from Here .

3edf1w
  • 105
  • 2
  • 9