This question already has an answer here:
- Can I mix MySQL APIs in PHP? 4 answers
I have problem with register form created in php mysql. I have form in html and php part with connection on db and insert query. I need to get input data from the form with _POST method and insert that in db. There are no errors it just wont submit it.
Here is my code:
<form action="registriraj.php" method="post" >
<div class="wrap-input100 validate-input m-b-23" data-validate = "Username is reauired">
<span class="label-input100">Ime:</span>
<input class="input100" type="text" name="imeregistracija" placeholder="Upišite ime">
<span class="focus-input100" data-symbol=""></span>
</div>
<div class="wrap-input100 validate-input" data-validate="Password is required">
<span class="label-input100">Prezime:</span>
<input class="input100" type="text" name="prezimeregistracija" placeholder="Upišite prezime">
<span class="focus-input100" data-symbol=""></span>
</div>
<div class="wrap-input100 validate-input m-b-23" data-validate = "Username is reauired" style="margin-top: 20px;">
<span class="label-input100">E-mail</span>
<input class="input100" type="email" name="emailregistracija" placeholder="Upišite E-mail">
<span class="focus-input100" data-symbol=""></span>
</div>
<div class="wrap-input100 validate-input" data-validate="Password is required">
<span class="label-input100">Lozinka</span>
<input class="input100" type="password" name="passregistracija" placeholder="Upišite lozinku">
<span class="focus-input100" data-symbol=""></span>
</div>
<button type="submit" class="btn btn-outline " style="background-color:#ff6e00;margin-top: 25px;" name="submit">Registriraj korisnika</button>
</form></div></center>
PHP code:
<?php
$connection = mysql_connect("localhost", "root", ""); // Establishing Connection with Server
$db = mysql_select_db("baza", $connection); // Selecting Database from Server
if(isset($_POST['submit'])){ // Fetching variables of the form which travels in URL
$imeregistracija = $_POST['imeregistracija'];
$prezimeregistracija = $_POST['prezimeregistracija'];
$emailregistracija = $_POST['emailregistracija'];
$passregistracija = $_POST['passregistracija'];
if($imeregistracija !=''||$passregistracija !=''){
//Insert Query of SQL
$query = "INSERT INTO `users` (`ime`, `prezime`, `user_pass`, `user_email`) VALUES ('dva','jedan','tri','cetri')";
echo "<br/><br/><span>Data Inserted successfully...!!</span>";
mysqli_query($connection, $query);
}
else{
echo "<p>Insertion Failed <br/> Some Fields are Blank....!!</p>";
}
}
mysql_close($connection); // Closing Connection with Server
?>
</div>