So I am using this form to submit to PHP file. PHP file has a redirect header that WORKS when I call the php file directly in browser, but when it is accessed via the action attribute in the form, it does nothing. There was a time I could make it redirect without the refresh: 2, but then the issue arose that it was only including the redirected file within the php document itself, so my javascript and submit functions would fail... Weird? Please advise! What's going on?
HTML
<form name="ats_routing" id="ats_routing" method="post" action="php/upload.php" enctype="multipart/form-data">
<!-- Some html generated by codiqa -->
<a onclick="submitForm();" data-transition="flip" data-theme="" data-icon="check">
Submit
</a>
</form>
Javascript part
/****CREATE JQUERY SUBMIT FUNCTION FOR IFRAME VALIDATION CHECK FOR Codiqa****/
function submitForm() {
if ($("#ats_routing").valid()) {
//alert("Thank You. Your Routing Form Has Been Submitted.");
$('#ats_routing').submit();
}
}
PHP that form redirects to (upload.php)
<?php
header("Refresh: 2; URL=/ats-routing/"); /* Redirect browser */
//Parse and store the db ini file, this will return an associative array
db_config_ats_ibutton();
db_connect();
$total_weight = $_POST['total_weight'];
$uf = $_POST['number_uf'];
$query="INSERT INTO datbasae (
lbs_uf,
total_weight,
district)
VALUES(
'$uf',
'$total_weight',
'$district')";
query_db($query);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title>ATS Routing</title>
<link rel="stylesheet" href="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.css">
<link rel="stylesheet" href="http://dev.rs.idmyasset.com/ats-routing/css/theme.css">
<!-- Extra Codiqa features -->
<link rel="stylesheet" href="https://codiqa.com/view/bb40208d/css">
<!-- jQuery and jQuery Mobile -->
<script src="https://d10ajoocuyu32n.cloudfront.net/jquery-1.9.1.min.js"></script>
<script src="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.js"> </script>
<meta http-equiv="refresh" content="2; url=http://dev.rs.idmyasset.com/ats-routing/">
</head>
<body>
<!-- Home -->
<div data-role="page" id="page1">
<div id="header" data-theme="" data-role="header">
<h3 id="header">
ATS Routing Data
</h3>
</div>
<div data-role="content">
<h1 align="center">Thank You</h1>
<h1 align="center">Your Form Has Been Submitted!</h1>
</div>
</div>
</body>
</html>