Create Table and Insert Data in Database in PHP?
Code -:
- index.php
- <?php
- $hostname = 'localhost';
- $username = 'root';
- $password = '';
- $databasename = 'testing';
- $username1 = "master-tech";
- $password1 = "123";
- //password encrypt
- $password1 = md5($password1);
- $master = mysqli_connect($hostname, $username, $password, $databasename); //database conneciton
- if($master) {
- echo "connection is established!..";
- //insert data
- $query = "INSERT INTO `login`(`username`, `password`) VALUES ('$username1', '$password1')";
- //execute
- $run = mysqli_query($master, $query);
- if($run) {
- echo "<br>insert data";
- }
- else{
- echo "<br>no data insert";
- }
- }
- else {
- echo "connection is not established!..";
- }
- ?>
No comments