hi having problem sending data database when send data connected buy no data found in database . new php ... please .
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>login file </title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.0/css/materialize.min.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.0/js/materialize.min.js"></script> </head> <body> <script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script> <div class="container"> <div class="row"> <form action="login_process.php" method="post"> <legend><h1 style="color:red;">form title </h1></legend> <div class="input-field col s6"> <div class="form-group"> <span class="help-block"></span> <input type="text" name="username" class="form-control" placeholder="username"> </div> </div> <div class="input-field col s6"> <div class="form-group"> <span class="help-block"></span> <input type="password" name="password" class="form-control" placeholder="password"> </div> </div> <button type="submit" class="btn">submit</button> </form> </div> </div> </body> </html> the connection file :
<?php $connection = mysqli_connect('localhost', 'root', '', 'demo'); if(!$connection) { die("database connection failed". mysqli_error()); } else {echo "connected";} ?> and process file :
<?php require_once 'connection.php'; if($connection) { echo "<h1>connected</h1>"; } if (isset($_post['submit'])) { $username = $_post['username']; $password = $_post['password']; $query = "insert user_tbl(username,password) values ('$username','$password')"; $result= mysqli_query($connection,$query); if (!$result) { die("query failed"); } } $result = mysql_query("select * user_tbl"); echo $result; ?>
your problem form.
your php script:
if (isset($_post['submit'])) is looking named variable should name="submit"
you checking submit button named submit not exist.
change
<button type="submit" class="btn">submit</button> to
<input type="submit" name="submit" class="btn" value="submit" />
Comments
Post a Comment