Posts

Showing posts from April, 2020

HOW TO DELETE DATA IN MYSQL USING PHP - CULT CODE

Image
            In this tutorial, we will learn how to DELETE data in MYSQL using PHP. 1. Create a table name user.   Use the code below to create a table:   CREATE TABLE `user` ( `id` int(11) NOT NULL, `username` varchar(251) NOT NULL, `email` varchar(251) NOT NULL, `password` varchar(251) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;             2. Now create a file connect.php: This file will help us to connect PHP to Mysql. <?php    $connect = mysqli_connect("localhost", "root", "password", "demo");    ?>   3. Now create a file index.php: In this file, we will create an HTML form and fetch data using PHP. <?php include('connect.php'); include('delete.php'); $data_query = "SELECT * FROM user LIMIT 1"; $data_result = mysqli_query($connect, $data_query); if(mysqli_num_rows($data_result) > 0) { while($r...

HOW TO UPDATE+FETCH DATA IN PHP - CULT CODE

Image
   In this tutorial, we will learn how to UPDATE+FETCH data in PHP using HTML form.   1. Create a table name user.   Use the code below to create a table:   CREATE TABLE `user` ( `id` int(11) NOT NULL, `username` varchar(251) NOT NULL, `email` varchar(251) NOT NULL, `password` varchar(251) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;                   2. Now create a file connect.php: This file will help us to connect PHP to Mysql. <?php    $connect = mysqli_connect("localhost", "root", "password", "demo");    ?>   3. Now create a file index.php: In this file, we will create an HTML form and fetch data using PHP. <?php  include('connect.php'); include('update.php'); $data_query = "SELECT * FROM user LIMIT 1"; $data_result = mysqli_query($connect, $data_query); if(mysqli_num_rows($data_result) > 0)...

HOW TO SEND EMAIL IN PHP USING HTML FORM - CULT CODE

Image
In this tutorial, we will learn how to send emails using HTML form in PHP.     Before starting make sure all email settings are set in php.ini 1. Create a file index.php: In this file, we will an HTML form. <?php include('emailserver.php');?>   <form action="" method="post" > <h3>PHP EMAIL</h3>   <input type="text" name="name" required placeholder="Name" /><br><br>   <input type="email" name="email" required placeholder="Email" /><br><br>   <textarea required name="message" placeholder="Write your message here..."></textarea><br><br> <input type="submit" value="SEND" name="send" ></input>   </form>   2. Now create a file emailserver.php: In this file, We will create an email server using PHP that will help us...

LOGIN/SIGNUP FORM WITH SESSION IN PHP MYSQL - CULT CODE

Image
In this tutorial, We will learn how to create a Signup and Login form in PHP MySql with Session Management and Exist condition. 1. Create a table name user.   Use the code below to create a table: CREATE TABLE `user` ( `id` int(251) NOT NULL, `username` text NOT NULL, `email` text NOT NULL, `password` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 2. Now create a file connect.php: This file will help us to connect PHP to Mysql. <?php $connect = mysqli_connect("localhost", "root", "password", "demo"); ?>   3. Now create a file index.php: After Signup/Sign-in user will be redirected to this page. <?php session_start(); if (!isset($_SESSION['username'])) { header("location: login.php"); } elseif (isset($_GET['logout'])) { session_destroy(); unset($_SESSION['username']); header("location: login.php"); } ?> <!DOCTYPE ht...

HOW TO INSERT DATA INTO MYSQL USING HTML FORM IN PHP - CULT CODE

Image
In this tutorial, we will learn how to insert data into MYSQL using HTML form in PHP. 1. Create a table name user.   Use the code below to create a table:   CREATE TABLE `user` ( `id` int(11) NOT NULL, `name` varchar(251) NOT NULL, `email` varchar(251) NOT NULL, `password` varchar(251) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;       2. Now create a file connect.php: This file will help us to connect PHP to Mysql. <?php $connect = mysqli_connect("localhost", "root", "password", "demo"); ?> 3. Now create a file index.php: In this file, we will create an HTML form. <?php include('dbconfig.php'); ?> <form method="post" action="" > <h3>HTML FORM</h3> <br> <input type="text" name="name" required placeholder="Name" /> <br> <br> <input type="email" name="email...

HOW TO FETCH SORTED/ORDERED DATA FROM MYSQL USING PHP - CULT CODE

Image
      In this tutorial, we will learn how to fetch sorted data from MYSQL using PHP with ORDER conditions. 1. Create a table name user.   Use the code below to create a table:   CREATE TABLE `user` ( `id` int(11) NOT NULL, `name` varchar(251) NOT NULL, `email` varchar(251) NOT NULL, `password` varchar(251) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;         2. Now create a file connect.php: This file will help us to connect PHP to Mysql. <?php $connect = mysqli_connect("localhost", "root", "password", "demo"); ?>   3. Now create a file index.php: Paste the below code in your index.php file. In this code, we will fetch data ordered by ASC name (A to Z) Ascending form . <?php include('connect.php'); $data_query = "SELECT * FROM user ORDER BY NAME ASC"; $data_result = mysqli_query($connect, $data_query); if(mysqli_num_rows($data_result) > 0) ...

HOW TO FETCH DATA FROM MYSQL WITH WHERE CONDITION USING PHP - CULT CODE

Image
    In this tutorial, we will learn how to fetch Selected rows from a table in PHP with the WHERE condition.     1. Create a table name user.   Use the code below to create a table:   CREATE TABLE `user` ( `id` int(11) NOT NULL, `name` varchar(251) NOT NULL, `email` varchar(251) NOT NULL, `password` varchar(251) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;       2. Now create a file connect.php: This file will help us to connect PHP to Mysql. <?php $connect = mysqli_connect("localhost", "root", "password", "demo"); ?>   3. Now create a file index.php: Paste the below code in your index.php file. <?php include('connect.php'); $data_query = "SELECT * FROM user WHERE id='5'"; $data_result = mysqli_query($connect, $data_query); if(mysqli_num_rows($data_result) > 0) { while($row = mysqli_fetch_array($data_resu...

HOW TO FETCH DATA FROM MYSQL USING PHP - CULT CODE

Image
    In this tutorial, we will learn how to fetch multiple rows from a table in PHP.       1. Create a table name user.   Use the code below to create a table:   CREATE TABLE `user` ( `id` int(11) NOT NULL, `name` varchar(251) NOT NULL, `email` varchar(251) NOT NULL, `password` varchar(251) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;       2. Now create a file connect.php: This file will help us to connect PHP to Mysql. <?php $connect = mysqli_connect("localhost", "root", "password", "demo"); ?>   3. Now create a file index.php: Paste the below code in your index.php file. <?php include('connect.php'); $data_query = "SELECT * FROM user"; $data_result = mysqli_query($connect, $data_query); if(mysqli_num_rows($data_result) > 0) { while($row = mysqli_fetch_array($data_result)) { ?> ...

HOW TO FETCH/SHOW A VARIABLE IN PHP - CULT CODE

Image
    1. Create a file name index.php. 2. Paste the code given below: index.php   <?php $name = 'John Doe';   echo "My name is $name"; ?> 3. Result:      

HOW TO CREATE A TABLE IN MYSQL USING PHPMYADMIN

Image
  In this tutorial, you will learn how to create a database and table in MYSQL using PHPMYADMIN. Before beginning, you need to download and install MYSQL, PHP, APACHE SERVER and PHPMYADMIN in your system. 1. Download MYSQL and Install it. Download MYSQL .   2. Download PHPMYADMIN. Download PHPMYADMIN.   3. Open a browser and type in URL http://localhost/phpMyAdmin-4.7.5-all-languages/     4. Sign in to your PHPMYADMIN:   5. After Sign in to your PHPMYADMIN, Click on the Databases: To create a table in Mysql first we need to Create a Database. 6. Create a Database: Enter your database name. Give it a name " Demo " 7. After creating a database now create a table: Enter the name of the table and numbers of rows and click on Go. (ex. Name = "user" and Rows="4"). 8. After clicking on Go, Now add details about row:  Make sure all fields look the same as below and click on Save. 9...