Can anyone help me to build a simple cms website. I already have the html and css code but my problem is how to insert php code in my html. Thanks
Hi @claudlanaza14, however simple your CMS might be, it won’t be that simple to build. You will need a fair bit of knowledge before you can accomplish the task.
To insert PHP code in your HTML make sure you have named the file ending with a .php extension. Then you can include your PHP code wrapped within the PHP tags:
<div><?php echo "Hello World!"; ?></div>
Yes, ant CMS is not simple, certainly not for a beginner in PHP.
And it’s really too big a subject to cover in a single topic, though you may get some tips on getting started and most likely will have lots more specific questions along the way.
It may be best to find a good tutorial or book on the subject. But do be warned that there is a lot of out-dated and poor quality content out there which can catch out the beginner. These days anyone can write and publish on-line a PHP tutorial, regardless of whether they know what they are doing.
I only say this because I see so many beginners come here learning php from the wrong places and using dreadfully out-dated and insecure code.
As a rule of thumb, avoid anything that uses the obsolete mysql
functions, you should be using mysqli
or PDO
to connect with your database.
Another tell-tale is outdated or poorly constructed HTML, as it generally goes hand in hand with PHP of a similar nature. I regularly see bad php along with bad html, things like <center>
tags, align
attributes, use of html for spacing, Eg, <br /><br />
or <p> </p>
If you see any stuff like that, run a mile and find something else.
Which brings us to:-
If things are being done properly, the logical, processing code will be kept as far as practical, separate from the html code that displays the page. So in it’s simplest form, you may have a controller script plus an html template file for a webpage (though it can get more complex).
But the point being, if what you are shown is a real jumble of a lot of PHP logic, mixed in with HTML code, it is likely another poor example of how to do things.
Hmm I’m also a Noob in PHP but I am learning just a few things to take note though.
-
When running php always save files in
.php
format -
the codes to start php are
<?php ?>
there are people saying<? ?>
also works but we dont know how long it may work though so stick to the first one. -
To run PHP offline make sure to get the php files needed which can be at the proper php website or use software like xampp and wampp.
Happy Learning If I missed anything just ask I’m just trying to be of help as these things also was an issue to solve when i began lol
How do you define what a CMS is? Many definitions say they are document management systems but that sure does not seem accurate to me.
I don’t understand “insert php code in my html”. If that is not answered in every article and book for PHP beginners then it might help to explain what you mean.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.