php - Variables wont insert into table ~ mysqli -
i'm posting form in html php.
i have connect.php connects database:
<?php $db = mysqli_connect('localhost','adam','password','easyfix', '3306'); if(mysqli_connect_errno()){ echo "failed connect mysql: " . mysqli_connect_error(); } ?>
i have register.php want insert variables html form.
<?php require 'connect.php'; $username = $_post["username"]; $email = $_post["email"]; $password = $_post["password"]; $cpassword = $_post["cpassword"]; //echo $username; //echo $email; //echo $password; //echo $cpassword; mysqli_query($db,"insert users (username, email, password) values ('". $username ."', '". $email ."', '". $password ."')"); or die(mysqli_error($db)); $mysqli->close($db); ?>
i've used echos make sure data posted, has. when comment out mysqli_query, echos displayed. when leave code is, echos not displayed , white page nothing inserted database.
i know should use prepared statements, wish data inserted before that.
i've checked out few similar answers on here have not found 1 work. variables not concatenated, thought fix issue nope.
here form:
<form action="../php/registration.php" method="post" name="login_form" class="form-signin" > <h3 class="form-signin-heading">register account!</h3> <hr class="colorgraph"> <br> <h4> username:</h4> <input type="text" class="form-control" name="username" placeholder="username" required="" autofocus="" /> </br> <h4> email:</h4> <input type="text" class="form-control" name="email" placeholder="email" required="" autofocus="" /> </br> <h4> password:</h4> <input type="password" class="form-control" name="password" placeholder="password" required=""/> </br> <h4> re-enter password</h4> <input type="password" class="form-control" name="cpassword" placeholder="password" required=""/> </br> <div class="btn-toobar"> <button type="submit" class="btn btn-primary">submit</button> </div> </form>
password
mysql reserved word , therefore should used backticks `:
insert users (username, email, `password`) ....
Comments
Post a Comment