Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- <form action="add_users.php" method="post">
- Login: <input type="text" name="login"><br>
- Password: <input type="text" name="password"><br>
- Imie: <input type="text" name="name"><br>
- Nazwisko: <input type="text" name="surname"><br>
- <input type="submit">
- </form>
- <?php
- /*
- $login = $_POST["login"];
- $password = $_POST["password"];
- $name = $_POST["name"];
- $surname = $_POST["surname"];
- */
- $mysql_host = 'localhost';
- $port = '3306';
- $username = 'root';
- $password = '';
- $database = 'library';
- try {
- $pdo = new PDO('mysql:host='.$mysql_host.';dbname='.$database.';port='.$port, $username, $password );
- $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $liczba = $pdo->exec('INSERT INTO `users_list` (`login`, `password`, `name`, `surname`) VALUES(
- \''.$_POST['login'].'\',
- \''.$_POST['password'].'\',
- \''.$_POST['name'].'\',
- \''.$_POST['surname'].'\')');
- if($liczba > 0)
- {
- echo 'Dodano: '.$liczba.' rekordow';
- }
- else
- {
- echo 'Wystąpił błąd podczas dodawania rekordów!';
- }
- } catch (PDOException $e) {
- print "Error!: " . $e->getMessage() . "<br/>";
- die();
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement