php - Inserting Data mysqli not working -
here html form section... cant understand 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 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 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 section 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 db_users(name, pass,login) values ('$name', '$pass', '$login')"; if (isset($_post["submit"])) { mysqli_query($con, $query); } ?>
this structure should be:
<?php $con = mysqli_connect("host","username","password","database name"); if (!$con) { die("failed databse connection"); } $name = $_post["name"]; $login = $_post["login"]; $pass = $_post["pass"]; $query = "insert db_users(name, pass,login) values ('$name', '$pass', '$login')"; if (isset($_post["submit"])) { mysqli_query($con,$query); } ?>
but error non posted keys in post array try this:
<?php $con = mysqli_connect("host","username","password","database name"); if (!$con) { die("failed databse connection"); } if (isset($_post["submit"])) { $name = $_post["name"]; $login = $_post["login"]; $pass = $_post["pass"]; $query = "insert db_users(name, pass,login) values ('$name', '$pass', '$login')"; mysqli_query($con,$query); } ?>
Comments
Post a Comment