Reputation: 44086
I have a this .htaccess rule for my lease form
RewriteRule ^(lease)$ index.php?route=$1 [L]
which i am using with this PHP to file the proper file
$industries = array();
while($row_r = mysql_fetch_assoc($result)){
$industries[] = $row_r;
}
if(isset($_REQUEST['route'])){
$route = rtrim($_REQUEST['route'], '/');
$home_page = ($route == '') ? true : false;
$parts = explode('/', $route);
}else{
$home_page = true;
}
if(!$home_page){
include($_SERVER['DOCUMENT_ROOT'] . '/inc/routes.php');
}
routes.php file
$valid_pages = array('newsletter_subscribe', 'lease',....
$file = $parts[count($parts) - 1];
if (in_array($file, $valid_pages)) {
include($_SERVER['DOCUMENT_ROOT'] . "/pages/$file.php");
exit;
}else{
include($_SERVER['DOCUMENT_ROOT'] . "/pages/404.php");
exit;
this works great and i an getting to a pages/lease.php file. All is good but on the lease.php file i have a form that posts to itself like this
<?php if((isset($_POST['submitform'])) && ($_POST['submitform'])) {
echo "<pre>".print_r($_POST)."</pre>";
}
<form action="/pages/lease.php" method="post" id="app_form" name="app_form" onsubmit="return checkForm();">
<input type="text" name="print_config" value="email">
<p><input type="submit" name="submitform" value="Submit Application"></p>
....
BUT the POST is always empty...why is that and how do I preserve it..am I missing something
Upvotes: 1
Views: 650
Reputation: 54797
Hmmm, ok:
As long as your rewrite rule doesn't actually redirect the page (but just rewrites the path internally), your POST data is preserved because it's still using the same HTTP request. Also pages/lease.php
doesn't match to the rule ^(lease)$
anyways...
Although I don't really know which part answered your question. I'm assuming it was the form's action.
Upvotes: 1