Advertisement
Guest User

Untitled

a guest
Dec 15th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. <!--<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <?php
  3. session_start();
  4. $username = $_POST['username'];
  5. $password = $_POST['password'];
  6.  
  7. if ($username === "admin" && $password === "tajna"){
  8.  
  9. header("Location: t7z1.php"); // Ako je korisnik npr guest da li trebam otvoriti drugaciju stranicu ili istu sa izmjenama?
  10. }
  11. else
  12. print "Greska!";
  13. ?>-->
  14. <html>
  15. <head>
  16. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  17. <title>Telefonski imenik</title>
  18. </head>
  19. <body>
  20. <table style="width:75%">
  21. <?php
  22. $podaci = file('data.csv');
  23. // var_dump($podaci);
  24. for($i = 0; $i < sizeof($podaci); $i++)
  25. {
  26. echo "<tr>";
  27. $red = explode(',', $podaci[$i]);
  28. for($j = 0; $j < sizeof($red); $j++)
  29. {
  30. echo "<td>";
  31. echo $red[$j];
  32. }
  33. echo "<td> <button onclick="."test()".">Uredi</button> </td> ";
  34. echo "<td> <button>Briši</button> </td> ";
  35. }
  36. ?>
  37. </table>
  38. <form method="post" action="">
  39. <?php
  40. if(isset($_POST['ime']) && isset($_POST['prezime']) && isset($_POST['brojTelefona']))
  41. {
  42. $file = fopen('data.csv', 'a');
  43. $fields = array($_POST['ime'], $_POST['prezime'], $_POST['brojTelefona']);
  44. fputcsv($file, $fields, ',', '"');
  45. // unset($_POST);
  46. // Zasto vise puta submita formu bez ove linije?!
  47. header('Location:'.$_SERVER['PHP_SELF']);
  48. fclose( $file );
  49. }
  50. ?>
  51. <input type ="text" name="ime" placeholder="Ime">
  52. <input type ="text" name="prezime" placeholder="Prezime">
  53. <input type ="text" name="brojTelefona" placeholder="Broj telefona">
  54. <input type ="submit" value = "Dodaj">
  55. </form>
  56. <script type="text/javascript" src="t7skripta.js"></script>
  57. </body>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement