Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <?php
- session_start();
- $username = $_POST['username'];
- $password = $_POST['password'];
- if ($username === "admin" && $password === "tajna"){
- header("Location: t7z1.php"); // Ako je korisnik npr guest da li trebam otvoriti drugaciju stranicu ili istu sa izmjenama?
- }
- else
- print "Greska!";
- ?>-->
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Telefonski imenik</title>
- </head>
- <body>
- <table style="width:75%">
- <?php
- $podaci = file('data.csv');
- // var_dump($podaci);
- for($i = 0; $i < sizeof($podaci); $i++)
- {
- echo "<tr>";
- $red = explode(',', $podaci[$i]);
- for($j = 0; $j < sizeof($red); $j++)
- {
- echo "<td>";
- echo $red[$j];
- }
- echo "<td> <button onclick="."test()".">Uredi</button> </td> ";
- echo "<td> <button>Briši</button> </td> ";
- }
- ?>
- </table>
- <form method="post" action="">
- <?php
- if(isset($_POST['ime']) && isset($_POST['prezime']) && isset($_POST['brojTelefona']))
- {
- $file = fopen('data.csv', 'a');
- $fields = array($_POST['ime'], $_POST['prezime'], $_POST['brojTelefona']);
- fputcsv($file, $fields, ',', '"');
- // unset($_POST);
- // Zasto vise puta submita formu bez ove linije?!
- header('Location:'.$_SERVER['PHP_SELF']);
- fclose( $file );
- }
- ?>
- <input type ="text" name="ime" placeholder="Ime">
- <input type ="text" name="prezime" placeholder="Prezime">
- <input type ="text" name="brojTelefona" placeholder="Broj telefona">
- <input type ="submit" value = "Dodaj">
- </form>
- <script type="text/javascript" src="t7skripta.js"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement