Header location: load contents into a page div
Here's the structure of the web site I'm building:
I have first.php which includes second.php.
In second.php I have a link to a form and I have the $_GET to get the url parameters sent at the last page of this structure.
form.php tells action.php (the last page of this structure) that the switch case is FORM. Inside case FORM I have:
header("Location: second.php?param1=OK¶m2=OK");
With this line I load second.php page with the parameters but what I need to load is first.php page including second.php along with the parameters so I can use the $_GET
Is there any way I can do that? Below the structure.
Thanks a ton!
first.php
I'm the first page<br><br>
<div style="width:500px;height:500px;border:2px solid red;"><?php include "second.php" ?></div>
second.php
<?php
$param1 = $_GET['param1'];
$param2 = $_GET['param2'];
?>
<script language="javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script>
$(document).ready(function(){
$("#theform").click(function(theevent){
$("#pre_target").html('<div id="target"></div>');
theform();
});
})
function theform() {
$("#target").load("form.php", {}, function(){ });
}
</script>
I'm the second page
<div id="pre_target">
<a href="#" id="theform">Go to form</a>
</div>
form.php
<form method="post" action="action.php">
<input type="hidden" name="ACTION" value="FORM">
<input type="submit" value="submit" name="submit"开发者_如何转开发>
</form>
action.php
<?php
switch($_REQUEST["ACTION"]) {
case "FORM":
header("Location: second.php#pre_target?param1=OK¶m2=OK");
break;
.
.
.
?>
If I understand your problem correctly, simply replace 'second.php' with 'first.php'. GET variables are SUPER Globals, meaning they are super, and global. second.php and first.php will share the same GET variables if first.php includes second.php.
header("Location: second.php?param1=OK¶m2=OK");
Change to:
header("Location: first.php?param1=OK¶m2=OK");
精彩评论