Forum Moderators: coopster

Message Too Old, No Replies

Using an include header pushes my page.

         

chaddsisco

12:26 pm on Sep 19, 2005 (gmt 0)

10+ Year Member



When I try to use the "include" to add in a header file, php put my header flush left and the all the html flush right. The footer seems to work fine but for some reason I cant get the header to work right any ideas? Thanks

***********************************************
header.inc
**********************************
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title><?php echo $page_title;?></title>
</head>
<body>
<bunch of html here - jatar_k>

<!-- PAGE SPECIFIC CONTENT STARTS HERE -->

***************************************************
the html part of the page
********************************************
<?php
include ('includes/header.inc');
?>
<?php
<bunch of php code here - jatar_k>
?>

<html>
<head>
<title>Here is your pic!</title>
</head>
<body>

<bunch of html here - jatar_k>

</body>
</html>
<?php
include ('includes/footer.inc');
?>

[edited by: jatar_k at 3:47 pm (utc) on Sep. 19, 2005]
[edit reason] stripped down the code [/edit]

jatar_k

3:52 pm on Sep 19, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I stripped your code so you could more easily see the issue

you just have an html problem

2 x <html>
2 x <head>
2 x <title>
2 x <body>

if you have those tags in the header.inc file then you can't have them in the html portion of the page or you will get them sent to the browser twice.

Take a look at the source in your browser and you can see it as well, 'view source' is your friend. ;)

chaddsisco

12:59 pm on Sep 20, 2005 (gmt 0)

10+ Year Member



Yeah I thought that might have been doing it also but when I remove the extra set of all thoose html tags I still get the same issue. Here is what the code looks like after I have taken out the extra html codes. Does anyone have any other ideas? Thanks in advance!

**************************************
header.inc
***********************************
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title><?php echo $page_title;?></title>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="4">
<tr> <!-- TOP ROW -->
<td rowspan="2" bgcolor="#FFFFFF"><img src="images/logo.jpg" alt="Balloon Crew" width="400" height="100" /></td>
<td width="*" bgcolor="#FFFFFF"><font color="#FFFFFF" size="+2" face="Courier New, Courier, mono"><strong>Balloon Crew</strong></font></td>
<td width="10" rowspan="2" bgcolor="#FFFFFF">&nbsp;</td>
</tr>
<tr> <!-- NAVIGATIONAL ROW -->
<td bgcolor="#003399">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="20%" align="center" bgcolor="#FFFFFF"><a href="admin.php">Main Admin Page</a></td>
<td width="20%" align="center" bgcolor="#FFFFFF"><a href="upload.php">Upload a picture</a></td>
<td width="20%" align="center" bgcolor="#FFFFF"><?php if (isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10)

!= 'logout.php')) {
echo '<a href="logout.php">Logout</a>';} else {
echo '<a href="login.php">Login</a>';}?></td>
<td width="20%" align="center" bgcolor="#FFFFFF" nowrap="nowrap"><a href="change_password.php">Change Password</a></td>
<td width="20%" align="center" bgcolor="#FFFFFF" nowrap="nowrap"><a href="delete.php">Delete a picture</a></td>
</tr>
</table>
</td>
</tr>
<tr> <!-- CONTENT ROW -->
<td bgcolor="#FFFFFF">&nbsp;</td>
<td bgcolor="#FFFFFF"><!-- PAGE SPECIFIC CONTENT STARTS HERE -->

***********************************************
the html page
**************************************

<?php
include ('includes/header.inc');
?>
<?php
//connect to the database
$link = mysql_connect("localhost", "admin", "pass")
or die("Could not connect: " . mysql_error());
mysql_select_db("gallery", $link)
or die (mysql_error());

//make variables available
$folder_location = $_POST['folder_location'];
$image_caption = $_POST['image_caption'];
$image_username = $_POST['image_username'];
$image_tempname = $_FILES['image_filename']['name'];
$today = date("Y-m-d");

switch ($folder_location) {
case "centerpieces":
$ImageDir = "/home/pigsinbe/public_html/ballooncrew/gallery/centerpieces/";
break;
case "classicdecor":
$ImageDir = "/home/pigsinbe/public_html/ballooncrew/gallery/classicdecor/";
break;
case "dancefloors":
$ImageDir = "/home/pigsinbe/public_html/ballooncrew/gallery/dancefloors/";
break;
case "deliverybouquets":
$ImageDir = "/home/pigsinbe/public_html/ballooncrew/gallery/deliverybouquets/";
break;
case "propsandeffects":
$ImageDir = "/home/pigsinbe/public_html/ballooncrew/gallery/propsandeffects/";
break;
case "stagedecor":
$ImageDir = "/home/pigsinbe/public_html/ballooncrew/gallery/stagedecor/";
break;
case "themedecor":
$ImageDir = "/home/pigsinbe/public_html/ballooncrew/gallery/themedecor/";
break;
case "tradeshows":
$ImageDir = "/home/pigsinbe/public_html/ballooncrew/gallery/tradeshows/";
break;
case "weddings":
$ImageDir = "/home/pigsinbe/public_html/ballooncrew/gallery/weddings/";
break;
default:
echo "Sorry, but the location you selected was not correct.<br>";
echo "Please hit your browser's 'back' button and try again.";
}

$ImageThumb = $ImageDir . "thumbs/";

$ImageName = $ImageDir . $image_tempname;

if (move_uploaded_file($_FILES['image_filename']['tmp_name'],
$ImageName)) {

//get info about the image being uploaded
list($width, $height, $type, $attr) = getimagesize($ImageName);

switch ($type) {
case 1:
$ext = ".gif";
break;
case 2:
$ext = ".jpg";
break;
case 3:
$ext = ".png";
break;
default:
echo "Sorry, but the file you uploaded was not a GIF, JPG, or " .
"PNG file.<br>";
echo "Please hit your browser's 'back' button and try again.";
}

//define what table the info will be placed in
switch ($folder_location) {
case "centerpieces":
$insert = "INSERT INTO gallery_centerpieces
(image_caption, image_date)
VALUES
('$image_caption', '$today')";
break;
case "classicdecor":
$insert = "INSERT INTO gallery_classicdecor
(image_caption, image_date)
VALUES
('$image_caption', '$today')";
break;
case "dancefloors":
$insert = "INSERT INTO gallery_dancefloors
(image_caption, image_date)
VALUES
('$image_caption', '$today')";
break;
case "deliverybouquets":
$insert = "INSERT INTO gallery_deliverybouquets
(image_caption, image_date)
VALUES
('$image_caption', '$today')";
break;
case "propsandeffects":
$insert = "INSERT INTO gallery_propsandeffects
(image_caption, image_date)
VALUES
('$image_caption', '$today')";
break;
case "stagedecor":
$insert = "INSERT INTO gallery_stagedecor
(image_caption, image_date)
VALUES
('$image_caption', '$today')";
break;
case "themedecor":
$insert = "INSERT INTO gallery_themedecor
(image_caption, image_date)
VALUES
('$image_caption', '$today')";
break;
case "tradeshows":
$insert = "INSERT INTO gallery_tradeshows
(image_caption, image_date)
VALUES
('$image_caption', '$today')";
break;
case "weddings":
$insert = "INSERT INTO gallery_weddings
(image_caption, image_date)
VALUES
('$image_caption', '$today')";
break;
default:
echo "Sorry, but the location you selected was not correct.<br>";
echo "Please hit your browser's 'back' button and try again.";
}
//insert info into image table

$insertresults = mysql_query($insert)
or die(mysql_error());

$lastpicid = mysql_insert_id();

$newfilename = $ImageDir . $lastpicid . $ext;

rename($ImageName, $newfilename);

}

//convert to thumbnails
$newthumbname = $ImageThumb . $lastpicid . ".jpg";

//set the dimensions for the thumbnail
$thumb_width = 150;
$thumb_height = 150;

//create the thumbnail
$largeimage = imagecreatefromjpeg($newfilename);
$thumb = imagecreatetruecolor($thumb_width, $thumb_height);
imagecopyresampled($thumb, $largeimage, 0, 0, 0, 0,
$thumb_width, $thumb_height, $width, $height);
imagejpeg($thumb, $newthumbname);
imagedestroy($largeimage);
imagedestroy($thumb);

?>

<h1>Success!</h1><br><br>
<p>Here is the picture you just uploaded to your server:</p>
<img src="gallery/<?php echo $folder_location;?>/<?php echo $lastpicid . $ext;?>" align="left">
<strong><?php echo $image_name;?></strong><br>
This image is a <?php echo $ext;?> image.<br>
It is <?php echo $width;?> pixels wide
and <?php echo $height;?> pixels high.<br>
It was uploaded on <?php echo $today;?>.
<center><p>Would you like to upload another picture?</p></center>
<form name="form1" method="post" action="check_image.php"
enctype="multipart/form-data">

<table border="0" cellpadding="5">
<tr>
<td>Location to upload picture<br>
<em>Example: Weddings</em></td>
<td><select name="folder_location">
<option value="" selected>Select a location....</option>
<option value="centerpieces">Center Pieces</option>
<option value="classicdecor">Classis Decor</option>
<option value="dancefloors">Dance Floors</option>
<option value="deliverybouquets">Delivery Bouquets</option>
<option value="propsandeffects">Props and Effects</option>
<option value="stagedecor">Stage Decor</option>
<option value="themedecor">Theme Decor</option>
<option value="tradeshows">Trade Shows</option>
<option value="weddings">Weddings</option>
</select>
</td>
</tr>

<td>Upload Image:</td>
<td><input name="image_filename" type="file" id="image_filename"></td>
</tr>
</table>
<br>
<em>Acceptable image formats include: GIF, JPG/JPEG, and PNG.</em>
<p align="center"><input type="submit" name="Submit" value="Submit">
&nbsp;
<input type="reset" name="Submit2" value="Clear Form">
</p>
</form>

<?php
include ('includes/footer.inc');
?>

****************************************
footer.inc
**************************************

<!-- PAGE CONTENT ENDS HERE --></td>
<td width="10" bgcolor="#FFFFFF">&nbsp;</td>
</tr>
<tr> <!-- FOOTER NAVIGATIONAL ROW -->
<td bgcolor="#FFFFFF">&nbsp;</td>
<td bgcolor="#003399" link="#FFFFFF"><div align="center"><small><a href="admin.php">Main admin page</font></a> <a href="upload.php">Upload a picture</a> <a href="login.php">Login</a> <a href="change_password.php">Change Password</a> <a href="delete.php">Delete a picture </a></small></div></td>
<td width="10" bgcolor="#FFFFFF">&nbsp;</td>
</tr>
<tr> <!-- COPYRIGHT ROW -->
<td bgcolor="#FFFFFF">&nbsp;</td>
<td bgcolor="#FFFFFF">
<div align="center"><font size="-1">Copyright © 2005 Balloon Crew &ordm; <a href="http://www.chaddsmith.com">Chaddsmith. com</a></font></div></td>
<td bgcolor="#FFFFFF">&nbsp;</td>
</tr>
</table> <!-- Script 6.2 - footer.inc -->
</body>
</html>

tomda

1:08 pm on Sep 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here is what the code looks like after I have taken out the extra html codes.

Hmmmmm... Not sure. Please remove all the unnecessary code and submit it once. I'll stick to what jatar said, you've got 2 html, 2 bodies, etc.

chaddsisco

2:32 pm on Sep 20, 2005 (gmt 0)

10+ Year Member



if you look at my last post you can see that I took out the extra set of html tag (html, body, etc) but yet the header still seems to be pushing the rest of the page to the right hand side. Any other ideas?

tomda

2:41 pm on Sep 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



View the source in your browser and save it as an html page.

Check the code source or validate it and I am sure you will find what the problem is. You can also modify the HTML page you have just created to find out what to modify in your PHP code to get it right.

jatar_k

2:41 pm on Sep 20, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



well it is only an html issue, view the page source in your browser that this script produces and play with that to figure out where your issue is.