Untitled

 avatar
unknown
plain_text
5 months ago
2.1 kB
3
Indexable
<?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'];
            $e_mail = $_POST['e_mail'];
            $username = $_POST['username'];
            $password = $_POST['password'];
            $sql = "INSERT INTO korisnici (ime,prezime,e_mail,k_ime,lozinka,uloga) VALUES('$ime','$prezime','$e_mail','$username','$password','kupac')";
            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>";
        }
    }
}
?>
<!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>
<body>
<form action="" method="post">
    <h2>Registracija</h2><br>
    <label for="ime">Ime</label>
    <input type="text" name="ime" id="ime" placeholder="unesite ime" required autofocus><br>
    <label for="prezime">Prezime</label>
    <input type="text" name="prezime" id="prezime" placeholder="unesite prezime" required><br>
    <label for="e_mail">Email</label>
    <input type="text" name="e_mail" id="e_mail" placeholder="unesite e_mail" required autofocus><br>
    <label for="username">Username</label>
    <input type="text" name="username" id="username" placeholder="unesite korisnicko ime" required><br>
    <label for="password">Lozinka</label>
    <input type="password" name="password" id="password" placeholder="unesite lozinku" required><br>
    <input type="submit" value="Registracija">
</form>
</body>
</html>
Editor is loading...
Leave a Comment