Advertisement
Guest User

Untitled

a guest
Feb 27th, 2014
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.80 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2.   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5.   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6.   <title>Gitarowe wojny - Dodaj swój najlepszy wynik</title>
  7.   <link rel="stylesheet" type="text/css" href="style.css" />
  8. </head>
  9. <body>
  10.   <h2>Gitarowe wojny - Dodaj swój najlepszy wynik</h2>
  11.  
  12. <?php
  13.   if (isset($_POST['submit'])) {    // POCZĄTEK
  14.    
  15.     $name = $_POST['name'];
  16.     $score = $_POST['score'];
  17.  
  18.     if (!empty($name) && !empty($score)) {
  19.      
  20.       $dbc = mysqli_connect('www.guitarwars.net', 'admin', 'rockit', 'gwdb');     // KONIEC
  21.  
  22.      
  23.       $query = "INSERT INTO guitarwars VALUES (0, NOW(), '$name', '$score')";
  24.       mysqli_query($dbc, $query);
  25.  
  26.      
  27.       echo '<p>Dziękujemy za dodanie rekordu!</p>';
  28.       echo '<p><strong>Imię i nazwisko:</strong> ' . $name . '<br />';
  29.       echo '<strong>Wynik:</strong> ' . $score . '</p>';
  30.       echo '<p><a href="index.php">&lt;&lt; Wróć do listy rekordów</a></p>';
  31.  
  32.      
  33.       $name = "";
  34.       $score = "";
  35.  
  36.       mysqli_close($dbc);
  37.     }
  38.     else {
  39.       echo '<p class="error">Wpisz wszystkie informacje, aby ' .
  40.         'dodać swój najlepszy wynik.</p>';
  41.     }
  42.   }
  43. ?>
  44.  
  45.   <hr />
  46.   <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  47.     <label for="name">Imię i nazwisko:</label>
  48.     <input type="text" id="name" name="name" value="<?php if (!empty($name)) echo $name; ?>" /><br />
  49.     <label for="score">Wynik:</label>
  50.     <input type="text" id="score" name="score" value="<?php if (!empty($score)) echo $score; ?>" />
  51.     <hr />
  52.     <input type="submit" value="Dodaj" name="submit" />
  53.   </form>
  54. </body>
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement