Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html lang="en">
- <head>
- <!-- Required meta tags -->
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <title>Hello, world!</title>
- </head>
- <body>
- <form action="" method="post">
- <input type="text" id="liczba1" name="liczba1" placeholder="liczba1">
- <input type="text" id="liczba2" name="liczba2" placeholder="liczba2">
- <input type="checkbox" id="checkbox" name="check" value="yes">Dodaj tego tysiaka
- <input type="submit" id="submit" name="submit" value="Oblicz">
- </form>
- </body>
- </html>
- <?php
- $localhost = 'localhost';
- $user = 'root';
- $password = '';
- $db_name = 'baza';
- $conn = mysqli_connect($localhost, $user, $password, $db_name);
- if(!$conn){
- echo 'nie polaczono';
- }
- if(isset($_POST['submit'])){
- $liczba1 = $_POST['liczba1'];
- $liczba2 = $_POST['liczba2'];
- $query = "INSERT INTO osoby (imie, nazwisko) VALUES ('{$liczba1}', '{$liczba2}')";
- $result = mysqli_query($conn, $query);
- if($result){
- echo 'dodano';
- }else{
- echo 'niedodano';
- };
- if(isset($_POST['check']) && $_POST['check']=='yes'){
- echo 'wcisnieto';
- };
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement