I am working on a task trying to submit a form in IE:
1.- When I am on page1.php and click “Submit”, I get a jQuery dialog box popup and then click “Yes, I accept”, it brings me to page2.php and if I click on “back” she brings me back to page1.php
2.- I also have php SESSION called inProgress, which sets the value to 1 when the user goes from page1.php to page2.php. This basically means that while the user clicks the Yes, I accept button only once, the user does not have to pop up to show more (even if the user goes back and forth).
Questions:
a) Somehow, when the user clicks the “Submit” button (on page 1.php), a popup appears and they automatically click on “Yes, I accept”, but then I don’t get a popup, even if I come back, what well. However, I would prefer to click the "Yes, I agree" button.
b) The main problem is that I keep showing the popup, even if I go back and forth when I use IE-11 (I want the popup to show only once).
How can I pop up to show ONLY ONCE after clicking “Yes, I accept” on IE-11, or, in other words, how can I make sure that the session is read on IE-11 correctly? I was thinking about using cookies with javascript, but I don't know how to implement this ... Someone is helping me. Thank you so much for the advanced! Here is my code for page1.php and page2.php
page1.php,
<?php
session_start();
if ($_POST) {
$_SESSION['inProgress'] = "1";
header("Location: page2.php");
exit;
}
?>
<html>
<head>
<title>Page1</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
</head>
<body>
<form id="homeForm" name="homeForm" method = "POST">
<input type = "submit" id="btnOpenDialog" name = "submit">
<input type="text" id="inProgress" value="<?php echo $_SESSION['inProgress'] ?>"/>
</form>
<h1>This is Page 1</h1>
<div id="dialog-confirm"></div>
<script type="text/javascript">
$(document).ready(function(){
$("#btnOpenDialog").click(function(){
var inProgress = $('#inProgress').val();
if (inProgress !== "1") {
$("#dialog-confirm").dialog({
resizable: false,
modal: true,
title: "Title",
height: 250,
width: 350,
closeOnEscape: false,
buttons: {
"Yes, I accept": function () {
$('#homeForm').submit();
},
"No, thanks": function () {
$(this).dialog('close');
}
}
});
}
});
});
</script>
</body>
</html>
page2.php
<html ng-app="store">
<head>
<title>Page1</title>
</head>
<body>
<h1>This is Page 2</h1>
<div id="dialog-confirm"></div>
<script type="text/javascript">
function myfunction() {
window.location.href="page1.php";
}
</script>
<input type="button" id="btnOpenDialog" onclick = "myfunction()" value="Back" />
</body>
</html>