Skip to content
Pakainfo

Pakainfo

Web Development & Good Online education

  • Home
  • Blog
  • Categories
  • Tools
  • Full Form
  • Guest Post
  • Advertise
  • About
  • Contact Us

how to disable back button in php

December 21, 2020 Pakainfo php Leave a comment
0
()

Today, We want to share with you how to disable back button in php?.In this post we will show you how to handle browser back button in jQuery, hear for how to handle browser back button in javascript? we will give you demo and example for implement.In this post, we will learn about Disable browser back button using jquery with an example.

How to disable browser back button using Jquery?

I can use window.history.pushState for restrict back button of browser in jquery or JavaScript. i can disable back button in browser using jquery in php source code or any mvc framework like PHP OOP, laravel, codeigniter or many more.

Read Also:  Disable browser back button using jquery

stop the browser back button using JavaScript

Example 1:

<!DOCTYPE html>
<html>
<head>
	<title>How to disable browser back button using Jquery? - www.pakainfo.com</title>
	<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
</head>
<body>
  
<button>click on browser back button</button>
  
</body>
   
<script type="text/javascript">
  $(document).ready(function() {
      window.history.pushState(null, "", window.location.href);        
      window.onpopstate = function() {
          window.history.pushState(null, "", window.location.href);
      };
  });
</script>
   
</html>

Example 2: Disable Back Button in Browser using JavaScript

<SCRIPT type="text/javascript">
	window.history.forward();
	function noBack() { window.history.forward(); }
</SCRIPT>
</HEAD>
<BODY onload="noBack();" 
	onpageshow="if (event.persisted) noBack();" onunload="">

Warn User if Back is Pressed

window.onbeforeunload = function() { return "You work will be lost."; };

how to disable back and forward button of browser in php?

login.php page :

<?php 
    if (isset($_POST['uname'], $_POST['pwd'], $_POST['type'])) {
        $Username = $_POST['uname'];
        $Password = $_POST['pwd'];
        $User_Type=$_POST['type'];
        if (!(empty($Username) || empty($Password) || empty($User_Type))) 
        {
             $model = new UsersModel();
             $rowsCount = $model->checkUser($Username,$Password,$User_Type);
             if ($rowsCount!=0)
             {
                  $_SESSION['user'] = $Username;
                  header("Location:LoginViewController.php");

             } else {
                  echo 'Bad user';
             }
        } else {
             echo 'Please, fill all inputs';
        }
    } else {
        echo 'Bad form sent';
    }
?>
<form name="f1" method="POST" action="" >
    // inputs
</form>

LoginViewController.php :

<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");

if (!isset($_SESSION['user'])) {
    header('Location: login.php');
    exit();
}
echo 'You have successfully logged as '.$_SESSION['user']
?>

logout.php :

<?php 
session_start();
session_destroy();
$_SESSION = array();
header("location: login.php");
?>

Download

I hope you get an idea about Restrict or Disable Browser Back Button.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Read Also:  defer parsing of javascript htaccess

How useful was this post?

Click on a star to rate it!

Free Live Chat for Any Issue

Related posts:

  1. how to disable browser back button in php?
  2. Disable browser back button using jquery
  3. jquery disable button
  4. Disable submit button until Ajax Completes Example
  5. css disable button
  6. How to Disable Submit Button After Click using jQuery?
  7. jQuery Disable Button After Click Example
  8. jQuery Enable Disable Submit Button Example
  9. Disable button after click html in jQuery – prevent multiple clicks
  10. VueJS conditionally Enable Disable button
Read Also:  PHP LinkedIn OAuth Login Integration Tutorial From Scratch
disable back button after logout javascriptdisable back button in browser using javascripthow to disable back and forward button of browser in phphow to disable back button in chrome using javascripthow to disable back button in javascripthow to disable back button in php after loginhow to disable browser back button in codeigniterhow to disable browser back button in jquery

Post navigation

Previous Post:php include file from another folder
Next Post:jquery drag and drop save to database php

Search

Write For Us

We’re accepting well-written informative guest posts and this is a great opportunity to collaborate.
Submit a guest post to [email protected]
Contact Us

Freelance web developer

Do you want to build a modern, lightweight, responsive website quickly?
Need a Website Or Web Application Contact : [email protected]
Note: Paid Service
Contact Me

Categories

3movierulz (49) Ajax (464) AngularJS (377) ASP.NET (61) Bollywood (93) Codeigniter (175) CSS (97) Earn Money (61) Education (53) Entertainment (109) fullform (79) Google Adsense (62) Highcharts (77) Hollywood (94) JavaScript (1355) Jobs (39) jQuery (1421) Laravel (1086) LifeStyle (50) movierulz4 (48) Mysql (1029) Mysqli (890) Node.js (39) php (2115) Programming (2326) Python (96) ReactJS (37) Software (111) Software (79) Stories (87) tamilrockers (89) Tamilrockers kannada (49) Tamilrockers telugu (48) Tech (120) Technology (2370) Tips and Tricks (110) Tools (131) Top10 (332) Trading (56) Trending (54) VueJs (250) Web Technology (85) webtools (145) wordpress (165) World (159)

Advertise With Us

Increase visibility and sales with advertising. Let us promote you online.
Click Here

A To Z Full Forms

Access a complete full forms list with the meaning, definition, and example of the acronym or abbreviation.
Click Here

  • Home
  • About Us
  • Terms And Conditions
  • Write For Us
  • Advertise
  • Contact Us
  • Youtube Tag Extractor
  • YouTube Monetization
  • Increase Domain Authority
  • Social Media Marketing
  • Freelance web developer
  • Tools
Pakainfo 9-OLD, Ganesh Sco, Kothariya Ring Road, Chokadi, Rajkot - 360002 India
E-mail : [email protected]
Pakainfo

© 2022 Pakainfo. All rights reserved.

Top
Subscribe On YouTube : Download Source Code
We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype YouTube Tag Extractor