-4

i want to create a simple comment system and i want to use the notepad or access to save the database (COMMENTS ) , i tend to use this codes below but it didnt work , I WANT TO ASK 1- IS IT RIGHT TO USE NOTEPAD FOR IMPLEMENT PHP CODES ? 2- IS IT RIGHT TO WRITE THE ALL PATH OF DESIRED FILE (WHICH I WILL SAVE ON IT ) ? 3- WHY THE COMMENT DIDNT SAVED IN THE NOTEPAD .

<?php
if ($_post)
{ 
    $name = $_POST('name');
    $content = $_POST('commentcontent');
    $handle = fopen("C:\Users\User\Desktop\simester8\text.txt", "a+");
    fwrite($handle,' $name  ', ' $content ');
    fclose($handle);


}



?>
NORAI
  • 5
  • 1

1 Answers1

2
  1. you could use mysql database
  2. you don't have to
  3. check out this page : http://www.tizag.com/phpT/filewrite.php

    if(isset($_POST['submit']))
    {    
    $handle = fopen("text.txt", "a+") or die("can't open file");
    $name   = $_POST['name'];
    $content = $_POST['commentcontent'];
    fwrite($handle, $name , $content );
    fclose($handle);
    }
    
    <form method="POST" action="<?=$_SERVER['PHP_SELF']?>">
    <input type=text name="name" id="name">
    <input type=text name="commentcontent" id="commentcontent">
    <button type="submit" value="submit" name="submit" class="btn">submit</button>
    </form>
    
rgerculy
  • 481
  • 5
  • 14