I'm having problem with registration form using php script, i am checked alot of posts for this type of issues and i'm stil not getting it.. i'm trying to write codes by myself to insert user into database after guest is trying to register new user..
I wrote code like that and i know it's not suppose to be like that but i'm atleas trying by myself to learn something and if you guys can help me give your professional tips what should i add and what should i remove to make secure and working code
PHP Code i wrote
<?php
include("dbconnect.php");
if (!isset($_POST['registracija'])); {
$uporabnik = $_POST['uporabnik']; #----------- Username ------------#
$email = $_POST['email'];#----------- Email ------------#
$geslo = $_POST['geslo'];#----------- Password ------------#
$geslo2 = $_POST['geslo2'];#----------- Confirm password ------------#
$spol = $_POST['spol']; #----------- Gender ------------#
if($geslo == $geslo2){ #----------- Password / password confirm ------------#
$msg = 'gesli se ujemata'; #----------- Passwords are same ------------#
} else {
$msg = 'gesli se ne ujemata'; #----------- Error confirm password ------------#
}
}
if (strcmp ($uporabnik, $email, $geslo, $geslo2, $spol) == 0) {
$sql = "INSERT INTO uporabniki (uporabnik, email, geslo, spol)
VALUES ('$uporabnik', '$email', '$geslo', '$spol')";
if (mysqli_query($conn, $sql)) {
echo "Registered Successfully!";
}
}
?>
and here is html version of registration form
<form method="Post" >
<?php if(isset($msg)) echo $msg; ?><br>
<label >Uporabniško ime</label>
<input type="text" name="uporabnik" placeholder="Username..." size="50" required/>
<br>
<label >Email</label>
<input type="email" name="email" placeholder="Email" size="50" required/>
<br>
<label>Spol</label>
<input type="radio" name="spol" value="moški" required> Moški
<input type="radio" name="spol" value="ženska" required> Ženska
<br>
<label>Geslo</label>
<input type="password" name="geslo" placeholder="Password..." size="50" required/>
<br>
<label >Ponovi geslo</label>
<input type="password" name="geslo2" id="geslo2" placeholder="Confirm password..." size="50" required/>
<input type="submit" name="registracija" id="registracija" value="Registracija">
</form>
I hope you guys won't judge me and you'll help me out so i can learn more.. I'm new at this Thank you for your time and tips!