Jump to content

php header with unclosed {


Cobra23

Recommended Posts

Hi Guys,

 

I have an header.php file with a unclosed { after logging into a system. I tried to include that header.php in my index.php file with a footer.php that has the closing }. However, php does not allow this and only allows it to have an open { and closting } on the same page. Is there a way around this so i can have the header.php and footer.php included in the index.php file?

 

index.php

<?php include('http://www.mydomain.com/login/header.php'); ?>
----- html code here ------
<?php include('http://www.mydomain.com/login/footer.php'); ?>

header.php

<?php
 mysql_connect("localhost", "user", "pass") or die(mysql_error()); 
 mysql_select_db("db") or die(mysql_error());
 if(isset($_COOKIE['ID_my_site'])) 
 {
 	$name = $_COOKIE['ID_my_site'];
 	$password = $_COOKIE['Key_my_site'];
 	$check = mysql_query("SELECT * FROM users WHERE name = '".$name."'") or die(mysql_error());
 	while($collect = mysql_fetch_array( $check ))
 		{
			$plan = $collect['plan'];
                        if ($password != $collect['password'])
 			{
				header("Location: http://www.mydomain.com/login/");
 			}			
			else if ($plan == 'MyPlan')
			{
			?>

footer.php

<?php
 			}
			else
 			{
				header("Location: http://www.mydomain.com/login/");
 			}
 		}
 }
 else
 {
 	header("Location: http://www.mydomain.com/login/");
 }
 ?>
Edited by Cobra23
Link to comment
Share on other sites

PHP statements cannot be split across multiple files.  I see no reason why you'd need to do that. All php files must be syntactically correct

 

 The code you posted is for handling the login. It would make more sense to have that code in its own file and then include that in header.php when required.

<?php

include 'process_login.php'; // include the file for processing site logins

// other php code for handling the site header
?>
... html code for the site header
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.