Jump to content

Recommended Posts

I have a form which when the submit button is pressed it should go to a different page.... but when i have an include to do with absolutely nothing relating to the page other than to display how much money the user has.. and what level they are it just refreshes the page rather than doing the relocation.

 

If i remove the include how ever it works .

 

 

Would any one know what sorta thing causes this so i can check it out ?

Link to comment
https://forums.phpfreaks.com/topic/67047-solved-include-prevents-submission-s/
Share on other sites

ok, the two codes work when seperated but not when together.

 

 

this is the include code:

 

 

 

<?
//connect include
include("include.php");

//include to allow $row assignments
include("homeloginvariables.php");




$Level = $row["Level"];
$Money = $row["MoneyInHand"];










//setting max courage
$EXP = $row["CrimeExp"];


?>



<div id='bv_' style='position:absolute;left:30px;top:118px;width:200px;height:19px;z-index:12' align='center'>
<font style='font-size:14px' color='#FFFFFF' face='Arial'><b>Level:<font color='#32CD32'> <?= $Level?></b></font></div>
<div id='bv_' style='position:absolute;left:130px;top:118px;width:200px;height:19px;z-index:12' align='center'>
<font style='font-size:14px' color='#FFFFFF' face='Arial'><b>Money: <font color='#32CD32'>£<?= $Money?></b></font></div>
<img src="energymax.jpg" id="Image2" alt="" align="top" border="0" width="125" height="5" style="position:absolute;left:380px;top:130px;z-index:1">


<?
//Energy Bar for user
$MaxEnergy = $row["MaxEnergy"];
$CurrentEnergy = $row["CurrentEnergy"];

$height = 5;
$width = 125;

$NewCurrentEnergy = ($CurrentEnergy / $MaxEnergy) * $width;
echo "<div id='bv_' style='position:absolute;left:340px;top:115px;width:200px;height:19px;z-index:12' align='center'>";
echo "<font style='font-size:12px' color='#FFFFFF' face='Arial'><b>Energy $CurrentEnergy/$MaxEnergy</b></font></div>";
echo "<img src='energycurrent.jpg' id='Image2' alt='' align='top' border='0' width='.$NewCurrentEnergy.'height='5' style='position:absolute;left:380px;top:130px;z-index:1'>";
?>


<img src="couragemax.jpg" id="Image2" alt="" align="top" border="0" width="125" height="5" style="position:absolute;left:580px;top:130px;z-index:1">




<?
//courage bar for user

$MaxCourage = $row["MaxCourage"];
$CurrentCourage = $row["CurrentCourage"];

$height = 5;
$width = 125;

$NewCurrentCourage = ($CurrentCourage / $MaxCourage) * $width;
echo "<div id='bv_' style='position:absolute;left:543px;top:115px;width:200px;height:19px;z-index:12' align='center'>";
echo "<font style='font-size:12px' color='#FFFFFF' face='Arial'><b>Courage $CurrentCourage/$MaxCourage</b></font></div>";
echo "<img src='currentcourage.jpg' id='Image2' alt='' align='top' border='0' width='.$NewCurrentCourage.'height='5' style='position:absolute;left:580px;top:130px;z-index:1'>";
?>
<img src="maxhappy.jpg" id="Image2" alt="" align="top" border="0" width="125" height="5" style="position:absolute;left:780px;top:130px;z-index:1">


<?


//happy bar for user



$HouseType = $houserow["HouseType"];




$MaxHappy = $row["MaxHappy"];
$CurrentHappy = $row["CurrentHappy"];


$height = 5;
$width = 125;

$NewCurrentHappy = ($CurrentHappy / $MaxHappy) * $width;
echo "<div id='bv_' style='position:absolute;left:740px;top:115px;width:200px;height:19px;z-index:12' align='center'>";
echo "<font style='font-size:12px' color='#FFFFFF' face='Arial'><b>Happy $CurrentHappy/$MaxHappy</b></font></div>";
echo "<img src='currenthappy.jpg' id='Image2' alt='' align='top' border='0' width='.$NewCurrentHappy.'height='5' style='position:absolute;left:780px;top:130px;z-index:1'>";
?>

 

 

This is the code that the user observes and interacts with:

 

if (isset($_POST['ShowHouses'])) {
session_start();
$Area = $_POST['RegionComboBox'];
$StreetName = $_POST['StreetComboBox'];
$_SESSION['Area'] = $Area;
$_SESSION['Streetname'] = $StreetName ;

If ($Area == " ") {	
				Die ('You must select a region!');
				}
ElseIf ($StreetName == "")
			{
				Die ('You must select a street name!');
			}
Else{
//this only works when the include is not included
header("Location: housepurchaselist.php");
}

well the first include just displays the user's energy bar happy bar and courage bar money and their level... which is a global include every page displays this.

 

the next code which is the page the user is viewing is "buy house" page which the user selects the region and street which once picked, the locate takes the user to the next page, which shows available houses for their choice.

 

It all works but if i have the energy bar etc showing on the page (which is also globally shown on every page of the entire site) this page doesn't seem to get along with it too well.. cos it cancels out the if statement at the start of the php of the latter script shown above.

But i have used the exact same if statement as shown below in this post with the energy bar included and they work fine but not this one, which is why im not even sure where to begin to look.

 

Referring to this if : if (isset($_POST['ShowHouses'])) {

 

instead of going through that "if" and eventually doing this "header("Location: housepurchaselist.php");" it just refreshes the page and shows the same page with no errors shown. And also the transaction never occurred as i echoed the variables and they were all blank.

If ($Area == " ") {

Die ('You must select a region!');

}
ElseIf ($StreetName == "")
{

Die ('You must select a street name!');
}
Else{
//this only works when the include is not included
header("Location: housepurchaselist.php");

 

 

 

So how would i logically do this so that the validation occurs and the header being afterwards?

well loads of things are being printed onto the screen from the include (the first script provided) shows that.

 

But i use the include on every page on the site. So i'm still not following too well with this as i've not done anything different to many other pages that have this sort of thing?

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.