Jump to content

oumyim

New Members
  • Posts

    1
  • Joined

  • Last visited

About oumyim

  • Birthday April 2

Profile Information

  • Gender
    Male
  • Interests
    want learn more

Contact Methods

  • Facebook
    gonz_02@yahoo.com
  • Twitter
    gonz02
  • Yahoo
    jonathan.onggon@yahoo.com.ph

oumyim's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. i dont have a idea how to delete and edit but i try to delete but when i delete it deleted all. without using MYSQL index.php <html> <head><title> PROJECT </title> </head> <body bgcolor="#B0FF30"> <div align="center" style="border:100px solid black"></br> <h2 style = "background-color:yellow;">PROJECT</h2> </div></br> <form action="add.php" method="post"> <font color="red"> <strong>ID</strong><input type= 'text' name = 'id'> <h6 style="font-family:verdana;">Name</h6><input type="text" name="name"><br> <h6 style="font-family:verdana;">Telephone</h6><input type="text" name="telephone"><br> <input type="submit" value="Add"> <input type="reset" value="Clear"> </font> </form> </body> </html> add.php <?php $fn = "file.txt"; $mode = "a"; $content = $_POST['id']." ".$_POST['name']." ".$_POST['telephone'].PHP_EOL; if($mode == 'w' || $mode == 'a'){ $file = fopen ($fn, $mode) or exit ("ERROR!!!!"); fwrite ($file, $content)."</br>"; } else { $file = fopen ($fn,$mode) or exit ("ERROR!!!!"); while (!feof($file)){ echo fgets ($file); } } fclose($file); echo "<script>window.location.href='view.php';</script>"; ?> view.php <html> <body bgcolor="#FFFF00"> <div align="center" style="border:80px solid red"> </div></br> </br><center> <?php $fn = "file.txt"; $mode = "r"; $file = fopen ($fn,$mode); ?> <table border="12"> <tr> <td>ID</td><td>Name</td><td>Telephone</td><td>Action</td> </tr> <tr> <?php while(!feof($file)){ $content = fgets($file); $val = explode(" ",$content); ?> <td><?php echo $val[0];?></td> <td><?php echo $val[1];?></td> <td><?php echo $val[2];?></td> <td><a href="update.php?id=<?=$row['id']?>">[Edit]</a> <a href="del.php?id=<?=$row['id']?>">[Delete]</a></td> </tr> <?php }?> <tr><td colspan="16"><a href="index.php" >Add New Record</a> </td></tr> </center> </table></br></br></br> <div align="center" style="border:80px solid red"> </div></br> </body> </html> edit.php <?php $fn = "file.txt"; $mode = "a"; $content= $POST_['name']."<br>".$_POST['telephone']; $name= ($_POST['name'])?$_POST['name']:''; $age= ($_POST['telephone'])?$_POST['telephone']:''; $id = ($_POST['id'])?$_POST['id']:''; if($name=="" || $telephone==""){ echo "<script>alert('Succesfully Verified');history.back();</script>"; }else{ $content("update users set name='".$name."', telephone='".$telephone."' where id='".$id."'"); echo "<script>alert('Record successfuly updated.');window.location.href='view.php';</script>"; } ?> <a href='view.php'> ==> Back to Home<==</a> update.php <?php $fn = "file.txt"; $mode = "a"; $file = fopen($fn, $mode); $name= ($_GET['id'])?$_GET['id']:''; $telephone= ($_GET['id'])?$_GET['id']:''; $id = ($_GET['id'])?$_GET['id']:''; ?> <html> <body> <div style="border:1px solid;"> <form action="edit.php" method="post"> <input type='hidden' name="id" value="<?=($_GET['id'])?$_GET['id']:''?>"></br> Name <input type="text" name="name" value="<?php $_GET['$name'];?>"></br> Telephone <input type="text" name="telephone" value=""<?php echo $_GET['$age'];?>"></br> <input type="submit" value="Update"> <input type="reset" value="Reset"> </form> <a href="view .php" >==>View Record List<==</a> </div> </body> </html> del.php <?php $fn = "file.txt"; $am = "w"; $file = fopen($fn, $am); $delete_record=$_GET['id']; if (isset($_GET['deleteid'])){ $content("delete from users where id='$delete_record'"); echo $delete_record.'Done deleted.'; } echo "<script>alert('Allright Na Delete.');window.location.href='view.php';</script>"; ?> and a notepad no text saved as file.txt sorry i can't reply for you andrea so i put my message here i used file.txt for displaying the to the notepad and viewing to that file.txt and you can view it in view.php
×
×
  • Create New...