Advertisement
Nikita051

Untitled

Jun 25th, 2022
922
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     $host = "localhost";
  3.     $user = "root";
  4.     $pass = "root";
  5.     $name = "test";
  6.     $link = mysqli_connect($host, $user, $pass, $name);
  7.    
  8.     session_start();
  9.  
  10.   if (!empty($_GET)) {
  11.     $surname = $_GET['surname'];
  12.         $name = $_GET['name'];
  13.         $query = "INSERT INTO users (surname,name) VALUES ('$surname','$name')";
  14.         mysqli_query($link, $query) or die(mysqli_error($link));
  15.         $_SESSION['flash'] = 'форма успешно сохранена';
  16.     header('Location: index.php');
  17.   };
  18.     if(isset($_SESSION['flash'])){
  19.         echo $_SESSION['flash'];
  20.         unset($_SESSION['flash']);
  21.     };  
  22.  
  23. ?>
  24. <form method="GET">
  25.     <input name="surname" placeholder="Фамилия"></br>
  26.     <input name="name" placeholder="Имя"></br>
  27.     <input type="submit">
  28. </form>
Advertisement
RAW Paste Data Copied
Advertisement