Jump to content

Header not to go anywhere


Lisa23

Recommended Posts

Hi is there a way that i can set header not go anywhere like the problem with this is that it still goes to the second header is there  a way i can set if none do nothing exit? and else do the second header??

<?php
if ($_POST['agents']=="none")
{
header("location:#");
exit;
  // header("Location: {$_SERVER['PHP_SELF']}");

}
else
{
header("location:http://www.xxxxxx.co.uk/tv/".$_POST['agents']."/index.php");	
}
?>

Link to comment
Share on other sites

my problem is that the form works like this

<form id="agents" action="agents_jump.php" method="post" name="agents" target="_blank" style="margin:0;">
<option value="none">Select</option>
<option value="1">Select</option>
<option value="3">Select</option>

 

and the agents_jump.php has the headers but what i want is if none dont jump to the agents_jump.php file or if it has to jump set a header to go back to previous page.

has at moment it still jumps to agents_jump.php file showing a blank file

<?php
if ($_POST['agents']=="none")  exit();

else header("location:http://www.estateagentsonfilm.co.uk/tv/".$_POST['agents']."/index.php");
?>

Link to comment
Share on other sites

Something like this?

if (isset($_POST['agents']) && $_POST['agents'] != "none")
header("Location: http://www.xxxxxx.co.uk/tv/".$_POST['agents']."/index.php");
exit();
}

 

Edit: Ignore me, I thought the agents_jump file was the same file that contained the form code :)

Link to comment
Share on other sites

almost perfect 1 small problem because the form opens in a new tab i opens the same page in a new tab is there a way if none either open the same page in the same tab or something like that?

 

if ($_POST['agents']=="none"){
      $last_page = $_SERVER['HTTP_REFERER'];
      header("Location: $last_page" same tab);
}

Link to comment
Share on other sites

well you have your form target set to blank, i would recommend getting rid of it so the form always opens in the same tab.. keeping the target blank and changing it upon $_POST['agents'] == "none" would require some JavaScript integration.. we can go that route if you want..

Link to comment
Share on other sites

The short answer is no.. Once the form is submitted the new window is created and PHP cannot access the original window.

Instead of using PHP to check that the field hasnt been changed from "none", you could use Javascript to ensure that the field was not left blank.

<script type="text/javascript">
function checkAgent() {
	if (document.getElementById('agent_select').selectedIndex == 0) {
		alert('Please select an Agent');
		return false;
	}
	return true;
}
</script>
<form  action="agents_jump.php" onsubmit="return checkAgent();" method="post" target="_blank" style="margin:0;">
<select name="agent" id="agent_select">
	<option value="none">Select</option>
	<option value="1">Agent 2</option>
	<option value="3">Select</option>
</select>
<input type="submit" value="Submit" />
</form>

Link to comment
Share on other sites

still took me to the other page when click submit button ii it cz i have the submit type has image perhaps

 <form id="agents" action="agents_jump.php" onsubmit="return checkAgent();" method="post" name="agents" target="_blank" style="margin:0;">

				<select name="agents" size="1" style="width:160px; font-size:13px;">
										<option value="none">Select</option>
<input class="view_agents" id="tvoption" type="image" src="images/viewagents.gif" alt="TV OPTION" name="tvoption"  border="0"   onclick="jwplayer().stop();">

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.