Untitled
unknown
plain_text
5 months ago
1.8 kB
3
Indexable
<!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"> <title>Document</title> </head> <?php require_once "spoj.php"; if(isset($_POST['username'])){ unset($error); $sql = 'SELECT * FROM korisnici WHERE ime = "'.$username.'"'; $result = mysqli_query($conn,$sql); if($result->num_rows > 0){ $error = "Korisničko ime zauzeto!<br>"; } else{ if(isset($_POST['username'])){ $ime = $_POST['ime']; $prezime = $_POST['prezime']; $username = $_POST['username']; $password = $_POST['password']; $sql = "INSERT INTO korisnici (ime,prezime,k_ime,lozinka,uloga) VALUES('$ime','$prezime','$username','$password','korisnik')"; if (mysqli_query($conn,$sql)){ header("location: ispis.php"); } else { echo "Error: " . $sql . ": -" . mysqli_error($conn); } mysqli_close($conn); echo "<h2>Unos uspiješan</h2>"; } } } ?> <body> <form action="" method="post"> <label for="ime">Ime</label> <input type="text" name="ime" id="ime" placeholder= "Unesite ime"> <br> <label for="prezime">Prezime</label> <input type="text" name="prezime" id="prezime"><br> <label for="username">Korisnicko ime</label> <input type="text" name="username" id="username"><br> <label for="password">Lozinka</label> <input type="password" name="password" id="password"><br> <input type="submit" value="Registriraj se"> </form> </body> </html>
Editor is loading...
Leave a Comment