Hi Everyone,
I want to start a 'just for fun' project to learn how to code in PHP. I have found that I can understand and even edit some code that is already written, but can't write it myself.
I've seen a couple websites written by two different Russians. I've noticed their way of programming seems different from ALL the PHP examples I can find on the Internet. The thing is... I REALLY like the way they build their sites and want to know how they do it.
I think I can reverse engineer one of the sites I have from them enough have some fun/success, but I'm stuck at the very beginning and don't know how to get passed it. I can't find ANYTHING on the web because I don't know the right question to ask or everyone's example is done the way I don't want to do.
Here's what I want to do:
I created a folder in htdocs (apache 2.2 ) to house the files/folders.
I created an 'image,' 'template,' and 'template/includes' folder
I created 3 files 'header.html,' 'menu.html,' and 'footer.html' and put them in the /template/includes
I created an index.php file and put it at root.
By inserting PHP code into the 'index.php' file I can pull the header, menu, and footer and have it displayed as expected, but that's not what I want to do.
Here's what I really want to do:
I want to put that index.php file in the 'templates' folder
I want to make another index.php file and put it at root. I want that when you refresh the site, it reads the index.php file at root and knows that my website homepage/index.php is located in 'templates' and then pulls that page along with the 'header, menu, and footer.'
I want to be able to put ' <#header#>, <#menu#>, and <#footer#> in the templates/index.php page and it's understood where these files are located and that the code from each of these pages is placed at that point.
That's it.
I BELIEVE?? the problem is that I must first place some kind of 'include' statement into the index.php file at root that tells where the homepage and these other files are located, but I'm not sure because in the Russian examples there are so many 'include' and 'required' statments that I'm not really sure.
What I'm hoping to get from someone here.
- Maybe 10 minutes of someone's time who would be willing to attach a few files here that would show how to do this. I'd like to drop them into my localhost folder and see it work and then look at how you did it. If you were even more helpful and wouldn't mind giving another five minutes, I would LOVE it if you could create a forms.php file (example) and put in only one db (first_name) field. Then create a page called input.html, where that db field might be called by using <#first_name#>. I THINK all of that could be done in about 6 very simplistic pages and in no more than 10-15 minutes by one of you PHP experts.
I want to learn it using this method because I loved the way these Russians kept ALL the form fields in one page, so you could see them all at once and then have it simply called in some .html page by using, for example, <#first_name#>. And, when you ran that page, you got a form text box right there where you could enter a name and then submit it to the MySQL db. It also worked in REVERSE. I would find on an output page something like <#first_name#> and sure enough the first name was pulled from db and placed there. The part that excites me is not the fact you can put data in a db from a form and retrieve it. I know we've been doing that for a long time. What I really like and want to learn is how to use "<#first_name#>" in a page and it works.
Is there anyone out there who finds this request simple enough who would be willing to demonstrate it for me in an actual website? If just these elements are there (nothing more), I should be able to understand it and then take my project much further by building on what I've just learned.
Thanks very much to anyone who's willing to do this.
P.S. Just so you know.. I don't ask this question lightly. I've searched the internet for hours trying to find an example of programming like this, but everyone seems to put their PHP code directly into the .html files and I'd like to try the other way. I finally figured I'm going to have to ask for help and joined here to see what I can learn.
Again, thank you for any help you're willing to provide.