Hello all.

Well I am trying to make a few pages on my site that my family will be able to access which will have 2 forms on it, one for item and one for webpage. I want each of the users to be able to enter information into the two forms and have it save them either to the page or to a seperate document so that each one of us can log on and look at each others wishlist.

I have experience in HTML and javascript however PHP is making me want to rip my hair out. If anyone has any suggestions on how to accomplish this or some ideas that would be terrific.

I was thinking something along the lines of a Guestbook but trimming down the extra info that isn't needed. Ideally I would like to be able to have radio buttons to check and then delete items they no longer want, but for now just being able to add items would be terrific.

Thank you to anyone who can help this extreme newb.

EDIT

OK so I read some more tutorials and I have this so far, seems to be almost exactly what I want. The one thing that I would like to add is a way to remove info from the log file, example remove the 3rd entry of 5 entries so users have a way to delete items.

Also I want to check the users entry for the website, if it is in "http://server.com" format I want to have it create a link (like it does to all now), if it is in "www.server.com", I want it to add the [url]http://,[/url] and if it is in Server format I want it to leave it alone.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>

<form method="post" action="<?php ?>" target="_self">
<label>Item
<input type="text" name="item" />
</label>
  <label for="textfield">Website</label>
  <input type="text" name="website" />
  <br />
  <button type="submit" name="Submit" value="Submit">Submit</button>

</form>

<?php
$w3 = '<a target="_blank" href="'
 ?>
 <?php 
 $w3end = '">'
 ?>
<?php 
if ($_POST['item'] == '' ){
}
else {
$ourFileName = "testFile.txt";
$ourFileHandle = fopen($ourFileName, 'a') or die("can't open file");
$stringData = "-".$_POST['item']."\n"."<br>";
fwrite($ourFileHandle, $stringData);
$url = strtolower($_POST['website']);
$stringData =  $w3.$url.$w3end.$url."</a>"."<br>";
fwrite($ourFileHandle, $stringData);
fclose($ourFileHandle);
}
?>
<?php 
$myFile = "testFile.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo $theData;
?>



</body>
</html>

    Hmm, I have something close by that might help you. Keep in mind it's very early here.. lol might not be bug-free.

    The way this is set up, you won't see any edit fields unless you pass the 'edit' variable through the url.
    http://www.domain.net/your_file.php?action=edit

    <?php
    /* EDIT */
    if($_GET["action"]=="edit" || $_POST["action"]=="edit")
    {
       if (!isset($_POST["submit"]))
       {
    	$edit = file_get_contents('testFile.txt');
          ?>
          <form name="myForm" action="your_file.php" method="post">
    <fieldset>
    <legend>Extras</legend>
    <textarea cols="60" rows="12" name="raw_data"><?php print $edit; ?></textarea>
    </fieldset>
    <br >
    <fieldset>
    <legend>Submit</legend>
          <input type="hidden" name="action" value="edit">
    <input type="reset" value="Clear">&nbsp;&nbsp;<input type="submit" name="submit" value="submit">
    </form>
    
       <? } ?>
    <?
       if ($_POST["$submit"])
       {	
       $fr = fopen('testFile.txt', 'a+');
       if(!$fr) {
          echo "Error! Couldn't open the file.";
       } else {
          fputs($fr, $raw_data); /* $raw_data is sent from the form */
          fclose($fr);
        }
       }
    }
    ?>
    

    As for testing if http:// is added to the website is pretty easy.

    <?php
    // tested & works
    function http($url)
    {
       $handle = "http://";
       $http = substr($url, 0, 7);
     if ($http == "http://") {
      return $url;
     } else {
      $domain = "$handle$url";
      return $domain;
     }
    }
    ?>
    

    Then add the function to your script. Which I unlike above, I haven't tested. But Should work fine.

    $ourFileName = "testFile.txt";
    $ourFileHandle = fopen($ourFileName, 'a') or die("can't open file");
    $stringData = "-".$_POST['item']."\n"."<br>";
    fwrite($ourFileHandle, $stringData);
      $suburl = http($_POST['website']);
      $url = strtolower($suburl);
    $stringData =  $w3.$url.$w3end.$url."</a>"."<br>";
    fwrite($ourFileHandle, $stringData);
    fclose($ourFileHandle);
    

    Good luck on your php adventures!
    http://www.php.net/ & PHP Builder will be your best friend.
    Hope this helps, cheers.

      Thanks for your help exponder, I did get a few things working because of it.

      The only thing that I am really missing is the easiest way I see for people to be able to delete items is if I made radio buttons appear in front of each item (not website) that appears so that if they no longer want the Item - PHPfordummies at Website www.xyz.com they can click a radio button in front of PHPfordummies (and any other unwanted item) and hit a delete button which removes it from testFile.txt.

      Again here is my code:

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html>
      <body>
      
      <form method="post" action="<?php ?>" target="_self">
      <label>Item
      <input type="text" name="item" />
      </label>
        <label for="textfield">Website</label>
        <input type="text" name="website" />
        <br />
        <button type="submit" name="Submit" value="Submit">Submit</button>
      
      </form>
      <?php
      $w3 = '<a target="_blank" href="'
       ?>
       <?php 
       $w3end = '">'
       ?>
       <?php 
       $urlstart = 'http://'
       ?>
      
      <?php 
      if ($_POST['item'] == '' ){
      }
      else {
      $ourFileName = "testFile.txt";
      $ourFileHandle = fopen($ourFileName, 'a') or die("can't open file");
      $stringData = "-".$_POST['item']."\n"."<br>";
      fwrite($ourFileHandle, $stringData);
      $url = strtolower($_POST['website']);
      $http = substr($url, 0, 4); 
      if ($http == "http"){
      $stringData =  $w3.$url.$w3end.$url."</a>"."<br>";
      }elseif ($http == "www."){
      $stringData =  $w3.$urlstart.$url.$w3end.$urlstart.$url."</a>"."<br>";
      }else{
      $stringData = $url."<br>";
      }
      fwrite($ourFileHandle, $stringData);
      fclose($ourFileHandle);
      }
      ?>
      <?php 
      $myFile = "testFile.txt";
      if (file_exists($myFile)) { 
      $fh = fopen($myFile, 'r');
      $theData = fread($fh, filesize($myFile));
      fclose($fh);
      echo $theData;}
      else{
      echo "No Data Yet";
      }
      ?>
      
      </body>
      </html>
      
        Write a Reply...