Here is my HTML with form section… I cant understand where is my mistake
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="loginStyle.css">
<link href="Bootstrap/css/bootstrap.min.css" rel="stylesheet">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1 user-scalable=no">
<link href='https://fonts.googleapis.com/css?family=Jura:600' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="Font Awseome Glyphicons/css/font-awesome.min.css">
<link href='https://fonts.googleapis.com/css?family=Lora:700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="Owl Carousel/owl-carousel/owl.carousel.css">
<link rel="stylesheet" href="Owl Carousel/owl-carousel/owl.theme.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12" style="margin-top:8%">
<h2 class="text-center">Be a Part of World</h2>
</div>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<form role="form" id="loginForm" action="regCheck.php" method="POST">
<div class="form-group">
<label for="regName">
<h4>Name</h4>
</label>
<input type="text" id="regName" class="form-control" placeholder="Your name here..." name="name">
<div class="alert"></div>
</div>
<div class="form-group">
<label for="regLogin">
<h4>Login</h4>
</label>
<input type="text" placeholder="Login Here..." id="regLogin" class="form-control" name="login">
<div class="alert"></div>
</div>
<div class="form-group">
<label for="regPass">
<h4>Password</h4>
</label>
<input type="password" placeholder="Password Here..." id="regPass" class="form-control" name="pass">
<div class="alert"></div>
</div>
<div class="form-group">
<input type="submit" value="Sign Up" class="btn btn-danger btn-lg" id="regSubmit" name="submit">
</div>
</form>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h3 class="text-center"><strong>...0r Join Us With</strong></h3>
</div>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-4">
<ul class="list-inline">
<li><a href="facebook.com"><span class="fa fa-facebook-official " aria-hidden="true"></span> Facebook</a>
</li>
<li><a href="twitter.com"><span class="fa fa-twitter" aria-hidden="true"></span> Twitter</a>
</li>
<li><a href="youtube.com"><span class="fa fa-youtube " aria-hidden="true"></span> Youtube</a>
</li>
<li><a href="instagram.com"><span class="fa fa-instagram " aria-hidden="true"></span> Instagram</a>
</li>
</ul>
</div>
</div>
</div>
<script type="text/javascript" src="JQuery/jquery-1.11.3.min.js"></script>
<script src="Owl Carousel/owl-carousel/owl.carousel.js"></script>
<script src="Bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="script.js"></script>
</body>
</html>
Here is section with checking registration
<?php
$con = mysqli_connect("localhost", "root", "");
if (!$con) {
die("Failed Databse Connection");
}
$name = $_POST["name"];
$login = $_POST["login"];
$pass = $_POST["pass"];
$query = "INSERT INTO db_users(name, pass,login) VALUES ('$name', '$pass', '$login')";
if (isset($_POST["submit"])) {
mysqli_query($con, $query);
}
?>
5
Answers
Your mysqli syntax is mixing with simple mysql
You have to give database name as last argument in mysqli_connect
You forgot to select the database
PHP manual for mysqli_connect()
This is the structure it should be:
But with that you would get an error as it will look for non posted keys in the POST array so try this:
Please mention DB name in mysqli_connect function.
You can use PHP database mysqli syntax and mention database name also in mysqli_select_db function as given below:
$connect = mysqli_connect(“database_hostname”,”database_username”,”database_password”);
mysqli_select_db($connect,”database_name”);