PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- <link rel="icon" href="#tukile ime slike in končnica" type="image/x-icon"> --> <link rel="stylesheet" href="styles.css"> <title>ZDP Napotnica</title> <style> input[type=text], input[type=date] { padding-left: 10px; border: 0px; border-bottom: 1px dotted #0070c0; text-align: center; } table { width: 57%; border: 1px dashed red; margin: 20px 10px; } label { color: #0070c0; } textarea { resize: none; border: 1px dotted #0070c0; } p { font-size: 10px; padding-left: 20px; color: #0070c0; } </style> </head> <body> <?php // Check if the form was submitted if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Sanitize and validate inputs $naziv = htmlspecialchars(trim($_POST['naziv'])); $davcna = htmlspecialchars(trim($_POST['davcna'])); $dejavnost = htmlspecialchars(trim($_POST['dejavnost'])); $dejavnost_koda = htmlspecialchars(trim($_POST['dejavnost_koda'])); $user_name = htmlspecialchars(trim($_POST['user'])); $emso = htmlspecialchars(trim($_POST['EMSO'])); $addres = htmlspecialchars(trim($_POST['addres'])); $post = htmlspecialchars(trim($_POST['post'])); $izob = htmlspecialchars(trim($_POST['izob'])); $poklic = htmlspecialchars(trim($_POST['poklic'])); $zaposlitev = htmlspecialchars(trim($_POST['zaposlitev'])); $delmesto = htmlspecialchars(trim($_POST['delmesto'])); $zadnjiZDP = htmlspecialchars(trim($_POST['zadnjiZDP'])); $ot = htmlspecialchars(trim($_POST['ot'])); $PPOT1 = htmlspecialchars(trim($_POST['PPOT1'])); // Ensure required fields are not empty if (!empty($naziv) && !empty($davcna) && !empty($user_name) && !empty($emso)) { // Use prepared statements for SQL query $stmt = $conn->prepare("INSERT INTO napotnica_data (naziv, davcna, dejavnost, dejavnost_koda, user_name, emso, addres, post, izob, poklic, zaposlitev, delmesto, zadnjiZDP, ot, PPOT1) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); // Bind parameters $stmt->bind_param("sssssssssssssss", $naziv, $davcna, $dejavnost, $dejavnost_koda, $user_name, $emso, $addres, $post, $izob, $poklic, $zaposlitev, $delmesto, $zadnjiZDP, $ot, $PPOT1); // Execute the query if ($stmt->execute()) { echo "<p>Data successfully inserted.</p>"; } else { echo "<p>Error: " . $stmt->error . "</p>"; } // Close statement $stmt->close(); } else { echo "<p>Please fill out all required fields.</p>"; } } // Close the database connection $conn->close(); ?> <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="POST"> <table> <tr> <td> <label for="naziv">Naziv in sedež delodajalca:</label> <input type="text" id="naziv" name="naziv" placeholder="Polni naziv podjetja z naslovom" maxlength="100" required> </td> </tr> <tr> <td> <label for="davcna">Davčna številka:</label> <input type="text" id="davcna" name="davcna" placeholder="" maxlength="10" required> </td> </tr> <tr> <td> <label for="dejavnost">Gospodarska dejavnost:</label> <input type="text" id="dejavnost" name="dejavnost" placeholder="klasifikacija glavne dejavnosti" maxlength="83" required> <input type="text" id="dejavnost_koda" name="dejavnost_koda" placeholder="koda 1" maxlength="10"> </td> </tr> <tr> <td> <label for="user">Ime in priimek delavca:</label> <input type="text" id="user" name="user" placeholder="Priimek in ime" maxlength="50" required> <label for="EMSO">EMŠO:</label> <input type="text" id="EMSO" name="EMSO" placeholder="EMŠO ali RD" maxlength="13" required> </td> </tr> <tr> <td> <label for="addres">Naslov:</label> <input type="text" id="addres" name="addres" placeholder="Naslov" maxlength="62" required> <input type="text" id="post" name="post" placeholder="Poštna številka in pošta" maxlength="50" required> </td> </tr> <tr> <td> <label for="izob">Izobrazba:</label> <input type="text" id="izob" name="izob" placeholder="Koda 2" maxlength="35"> <label for="poklic">Poklic:</label> <input type="text" id="poklic" name="poklic" placeholder="Poklic" maxlength="55"> </td> </tr> <tr> <td> <label for="zaposlitev">Zaposlen pri nas od:</label> <input type="date" id="zaposlitev" name="zaposlitev" required> <label for="delmesto">Delovno mesto:</label> <input type="text" id="delmesto" name="delmesto" placeholder="Delovno mesto" maxlength="59"> </td> </tr> <tr> <td> <label for="zadnjiZDP">Zadnji pregled dne:</label> <input type="date" id="zadnjiZDP" name="zadnjiZDP" required> </td> </tr> <tr> <td> <label for="ot">Ocena tveganja opravljena dne:</label> <input type="date" id="ot" name="ot" required> </td> </tr> <tr> <td> <label for="PPOT1">Kratek opis delovnega procesa:</label><br> <textarea id="PPOT1" name="PPOT1" rows="3" cols="122" maxlength="372"></textarea> </td> </tr> <tr> <td> <input type="submit" value="Submit"> </td> </tr> </table> </form> </body> </html>
Show:  
Copy Clear