HUB OF TUTORIALS
  • Business
  • Digital Marketing
  • Technology
    • HTML
    • CSS
    • jQuery
    • WordPress
    • Core PHP
    • Mysql
    • JAVA
    • Projects
    • Photography
  • Recipes
  • Others
  • Write for Us
HUB OF TUTORIALS
  • Business
  • Digital Marketing
  • Technology
    • HTML
    • CSS
    • jQuery
    • WordPress
    • Core PHP
    • Mysql
    • JAVA
    • Projects
    • Photography
  • Recipes
  • Others
  • Write for Us
  • Business
  • Digital Marketing
  • Technology
    • HTML
    • CSS
    • jQuery
    • WordPress
    • Core PHP
    • Mysql
    • JAVA
    • Projects
    • Photography
  • Recipes
  • Others
  • Write for Us
HUB OF TUTORIALS
  • Business
  • Digital Marketing
  • Technology
    • HTML
    • CSS
    • jQuery
    • WordPress
    • Core PHP
    • Mysql
    • JAVA
    • Projects
    • Photography
  • Recipes
  • Others
  • Write for Us
Core PHPHTMLMysql

How to Make Active or Inactive in PHP With Mysql Database

Why need status active and inactive in PHP?

Making any task, user, or function active or inactive is the most important part and essential feature of any web application or website. It is also known as blocking or unblocking of user accounts. Some times user performs irrelevant activities and the ones required to deactivate his or her account. By doing this we make that user’s status 0 in the database. In this way when the user tries to log in to his or her account, his login activity is failed. Database successfully login only those accounts whose status is 1 in the database table with active PHP. In this way, we can control inappropriate activities.

Table of contents
  1. Why need status active and inactive in PHP?
  2. Connectivity of Active PHP Web Application
    1. mysql_connect()
  3. Run The Code of status active and inactive in PHP-
    1. mysql_close() 
    2. We will Explain How to Make Active or Inactive in PHP With Database.
    3. Read More on Facebook

Here we are providing you 100% working code. Just copy the code and run it on your machine.

Connectivity of Active PHP Web Application

In order to create a PHP active dynamic web application, we need to have tables and databases created in the MySql database. After creating them we need to establish the connection between active PHP web application and MySQL Database.

Every database has a unique username and password to connect the database and manipulate.

$username = “your_name”;

$password = “your_password”;

$database=”your_database”;

$hostname = “localhost”;

mysql_connect()

The mysql_connect() function is used to connect the MySQL database and active PHP web application.

Now, Connect your PHP script to the MySQL database using the mysql_connect function. The first thing to do is connect to the database, the mysql_connect function is used to connect the MySQL database. The mysql_connect function returns a pointer to the database connection, called database handle.

mysql_connect($hostname, $username, $password)

mysql_connect(‘localhost’,’root’,”);

mysql_select_db(‘database’);

Now, these two lines of code finally establish a connection between the active PHP web application and MySql Database.

Run The Code of status active and inactive in PHP-

When you follow the procedure carefully and you are sure about your code then it’s time to check it. You need to create a table in the MySQL database otherwise it will not show anything

Read Also –  How to fetch data from Mysql database

mysql_close() 

It is used to close the connection.

Hostinger Web Hosting

We will Explain How to Make Active or Inactive in PHP With Database.

<?php
mysql_connect('localhost','root','');
mysql_select_db('database');
if(!empty($_GET['status_id'])&&isset($_GET['status_id']))
		{
			$status_id = $_GET['status_id'];
			$status = $_GET['status'];
			$query = "update menus set status = '$status' where id = '$status_id'";
			mysql_query($query);
			header("location:menus.php");
		}
	// Active / De-Active Record
?>
<html>
<head>
<title>Active/Deactive</title>
</head>
<body>
<form method="POST">
<table border="1">
			<?php 
				
				$query = "select * from table";
				$result = mysql_query($query);	
				
				$row = mysql_fetch_assoc($result)
			?>
			
			<tr>	
				
			<th>Items db</th>
				<?php
					$status =  $row['status']; 
					if($status == 1):	
				?>
				<td style="text-align:center;">
					<a href="menus.php?status_id=<?php echo $row['id'];?>&status=0">
						<img src="ok.png" title="Active / Deactivate Record" />
					</a>
				</td>
				<?php else:	?>
				<td style="text-align:center;">
					<a href="menus.php?status_id=<?php echo $row['id'];?>&status=1">
						<img src="cross.png" title="Active / Deactivate Record" />
					</a>
				</td>
				<?php endif; ?>
				</tr>
</table>
</form>
</body>
</hrml>

For all the above data/code to establish on the web, some sort of hosting is required to make your work online for others no matter who is accessing it until or unless the user is legit. Web hosting will bring traffic to your site and more people will learn about your work as well. Moreover, the data at the backend will be provided to you whenever any uses wishes to work on your webpage, so this will obviously enhance productivity. Further, the active and inactive approach is applied so no irrelevant user would be able to do spam work, hence only relevant and legit data will be taken under consideration. So, rightful hosting is required while making websites online on the server, to choose the appropriate one here is the list of Top 10 Web Hosting Companies that are 100% verified and are on the top categories, plus provide absolute amazing services as per the requirements one wishes to have.

Read More on Facebook

active and deactive in php active php change status using ajax in php how to set active and inactive in php online user counter php code php active status active and inactive in php
How to Create a Login system in PHP Using a SessionPrevHow to Create a Login system in PHP Using a SessionMarch 17, 2020
How to File Upload in Database using PHPMarch 17, 2020How to File Upload in Database using PHPNext
Search
Recent Posts
  • 7 Educational Approaches for Diverse Learners
  • 5 Best Online Payment Gateways in India
  • How to Start and Earn from Making WooCommerce Plugins
  • Step By Step Guide to Becoming a Certified Salesforce Developer
  • A Guide to Transitioning from On-Premises to Azure Services
Categories
  • Business
  • Core PHP
  • CSS
  • Digital Marketing
  • HTML
  • JAVA
  • Jobs
  • jQuery
  • Mysql
  • News
  • Others
  • Photography
  • Projects
  • Recipes
  • WordPress

  • How to Create List in HTML
  • How to use Iframe in HTML
  • How to Create a Table in HTML and CSS
  • How to Add New HTML Content using jQuery
  • CSS Property of List tag in HTML
  • How to use CSS for Table in HTML
  • How to Make Basmati Rice Recipe
  • How to Make Indian Kheer Recipe
  • How to Make Spicy Aloo Tikki
  • How to Make Aloo Matar Samosa
  • How to Make Cheese Potato Sandwich
  • How to Make Aloo Palak Methi
  • Company Visitors Management System
  • Complaint Management System using PHP
  • Directory Management System
  • Employee Record Management System
  • Hospital Management System using PHP
  • Vehicle Parking Management System

Copyright © 2022 Hub of Tutorials. All Rights Reserved. Designed by AS Webworks