Config.php
<?php
$host = "localhost";
$user = "root";
$pass = "";
$dbname = "nova";
$conn = mysqli_connect($host, $user, $pass, $dbname) or die();
?>
adddata.php
<?php
$email = $_POST['email'];
$username = $_POST['username'];
$password = $_POST['password'];
include 'db.php';
$sql = "INSERT INTO names(email, username, password)VALUES('$email','$username','$password')";
$result = mysqli_query($conn, $sql);
if($result){
header('Location:database.php');
}
?>
Database.php
<h1>List of Contact</h1>
<table border="2">
<tr>
<th>Username</th>
<th>Password</th>
</tr>
<?php
include 'db.php';
$sql = "SELECT * FROM names";
$result = mysqli_query($conn, $sql);
if ($result) {
while($row = mysqli_fetch_assoc($result)){
$id = $row['id'];
$email = $row['email'];
$password = $row['password'];
?>
<tr>
<td><?php echo $email ?></td>
<td><?php echo $password ?></td>
</tr>
<?php
}
}
?>
</table>
Post a Comment