Update Data in database using PHP with practical?
Code -:
- index.php
- <?php
- $hostname = 'localhost';
- $username = 'root';
- $password = '';
- $databasename = 'testing';
- $username1 = "master-tech";
- $password1 = "123";
- //password encrypt
- $password1 = md5($password1);
- $u_name = 'hello908';
- $master = mysqli_connect($hostname, $username, $password, $databasename); //database conneciton
- if($master) {
- echo "connection is established!..";
- //insert data
- $query = "UPDATE `login` SET `username`= '$u_name' WHERE id=6";
- //execute
- $run = mysqli_query($master, $query);
- if($run) {
- echo "<br>update data";
- }
- else{
- echo "<br>no data update";
- }
- }
- else {
- echo "connection is not established!..";
- }
- ?>
No comments