Cobra23 Posted June 6, 2014 Share Posted June 6, 2014 (edited) 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 June 6, 2014 by Cobra23 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.