Cobra23 Posted June 6, 2014 Share Posted June 6, 2014 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/"); } ?> Link to comment https://forums.phpfreaks.com/topic/289011-php-header-with-unclosed/ Share on other sites More sharing options...
Ch0cu3r Posted June 6, 2014 Share Posted June 6, 2014 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 https://forums.phpfreaks.com/topic/289011-php-header-with-unclosed/#findComment-1482046 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.