Archive for the ‘PHP’ Category

Including PHP files in HTML

March 17, 2008

Pestered by a couple of my friends and especially from the last comment i got on my previous post, i think its time to put on my thinking cap along with some glucon-D in my mouth and throw some real ‘geeky’ stuff at you guys with some cheesy lines like this to increase the word count.

So, early last month, i took up this project to develop the website for the CSE department of our college and since then have been working on it. PHP is the primary language that i’m using along with a bit of javascript here and there. Now, the most interesting part of programming in PHP i liked is its integration with MySQL, which helps create a database for all the information you ask it to store.
Another flexibility of PHP is that you can include PHP files in between HTML code. Just go <?include('filename.php')?> and your php file would be embedded in the area of the code. Though this worked fine for me but it screwed up my html page, all the html code written after the above include statement wasn’t displayed at all. So i had my php code embedded in the html template, while the html written after the php went all blank.

So i scanned thorough my php file, and there an additional usage of a function caught my eye. Heres the code.


//filename.php
//here form is an object of class in which displayForm is a defined function.
if(!isset($_POST['Button']))
{
$form->displayForm("register.php");
exit();
}

the exit() at the end of the php file did not allow the html code to work. So when i removed the exit() function, it worked like a charm. And for all this i spent an entire day searching for syntax errors and stuff.

Now that i’ve completed the registration form and the profile form for both faculty and students. Well for the profile pages i stole some ideas from orkut ;) Now i’m thinking of developing a discussion forum. Though a friend of mine suggested me to use phpBB, but the fact that i dont want so many advanced features on a department website has spurred me to come up with something of my own. Have worked it out on paper, it awaits its entry on the ZDE!!