Posts

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...