PHP Redirect Not Working When Using Form Action to Submit to PHP Page -
so using form submit php file. php file has redirect header works when call php file directly in browser, when accessed via action attribute in form, nothing. there time make redirect without refresh: 2, issue arose including redirected file within php document itself, javascript , submit functions 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"> <!-- html generated codiqa --> <a onclick="submitform();" data-transition="flip" data-theme="" data-icon="check"> submit </a> </form>
javascript part
/****create jquery submit function iframe validation check codiqa****/ function submitform() { if ($("#ats_routing").valid()) { //alert("thank you. routing form has been submitted."); $('#ats_routing').submit(); } }
php form redirects (upload.php)
<?php header("refresh: 2; url=/ats-routing/"); /* redirect browser */ //parse , store db ini file, return associative array db_config_ats_ibutton(); db_connect(); $total_weight = $_post['total_weight']; $uf = $_post['number_uf']; $query="insert 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"> <!-- codiqa features --> <link rel="stylesheet" href="https://codiqa.com/view/bb40208d/css"> <!-- jquery , 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>
first , important: there no http header named "refresh". browsers might react it, not defined.
so why use it? emitting html, not need refresh
http header. remove it.
which brings me refresh
meta tag. 1 work, or supposed work?
currently creating confusing situation browser: present 2 different values url got after 2 seconds. 1 http header, isn't official? should take precedence on meta tag other http header, or exception because non-standard http headers , standard meta tags other way round?
and different: code attackable sql injections. escape variable content goes sql statement!
Comments
Post a Comment