Skip to content

Instantly share code, notes, and snippets.

@incubs
Created January 6, 2017 03:02
Show Gist options
  • Save incubs/0df1812b131cef1a5e959b728366cf23 to your computer and use it in GitHub Desktop.
Save incubs/0df1812b131cef1a5e959b728366cf23 to your computer and use it in GitHub Desktop.
<?php
//insert into database
// create save.php file and write this code there, submit from a from which has fields, [message, name, password]
$name = $_POST['name'];
$message = $_POST['message'];
$password = $_POST['password'];
$query = "insert into users (name, message, password ) VALUES( '$name', '" .$message ."', '$password')";
$query = "select * from users";
$mysql = mysqli_connect('localhost','root','','leapfrog');
$result = mysqli_query( $mysql, $query);
//select from database
//make a new file list.php and write this code there to show this data in a table
$query = "select * from users";
$mysql = mysqli_connect('localhost','root','','leapfrog');
$result = mysqli_query( $mysql, $query);
while( $row = mysqli_fetch_assoc( $result ) ) {
echo "My name is " . $row['name'] . "<br/>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment