Jump to content

How do I integrate my HTML pages with PHP?


JohnCP

Recommended Posts

Hi all, I am very new at web developing, I currently work as a Java Programmer, and am extremely interested in learning how to create dynamic web pages and to hopefully create some business for myself...Just had a few questions on creating thin client apps:1. How do I know when to use a server side scripting language in my code? i.e. PHP, ASP integrated with my HTML code...2. What are the basic tools I need on my laptop to start developing server side web apps? I apologize if my use of terms doesn't make much sense, but i'm hoping you guys know what i'm trying to ask...basically, i'm just trying to get my foot off the ground..any advice would be helpful and much appreciated...Thanks again, JohnCP

Link to comment
Share on other sites

answering your questings...1: you only use it when you need to. if for example you wanted to change the title of the page by changing some things in your address bar, you would do this:

<html><head><title><?php echo $_GET['title']; ?></title></head>...etc

and in the address bar you type: http://www.domain.com/index.php?title=Hello%20Worldjust make sure that if there's php code in the page, it must have a .php extention.2: The best tool for PHP development is notepad and your internet conection. php.net has some amazing reference materials and w3schools forum is perfect to ask for help. That's all I use and I'm a n00b myself.I would recommend just playing around with variables. To call a variable from a form post use $_POST['variablename']; and from the address bar use $_GET['variablename'];. If they are just variables in the script, then you could just use $variablename;. Remember that all php must be in the php tags. When sending variables through links (like in the address bar use http://domain.com/index.php?variablename=variablevalue and when you want to add more vaiables just add & like http://domain.com/index.php?variablename=v...tle=demo&page=2

Link to comment
Share on other sites

Calvin, Thank you very much for your response....I guess my main question is how do you know WHEN you're supposed to use a server side scripting language such as PHP, ASP, etc...? for example, let's say you were to build a home website for company xyz. The site was to consist of a home page, company overview, employees, products, a page to buy their products, store locators...etc....when would server side scripting come into play? I hope i didn't confuse you with my jargon. Thanks again, JohnCP

answering your questings...1: you only use it when you need to. if for example you wanted to change the title of the page by changing some things in your address bar, you would do this:
<html><head><title><?php echo $_GET['title']; ?></title></head>...etc

and in the address bar you type: http://www.domain.com/index.php?title=Hello%20Worldjust make sure that if there's php code in the page, it must have a .php extention.2: The best tool for PHP development is notepad and your internet conection. php.net has some amazing reference materials and w3schools forum is perfect to ask for help. That's all I use and I'm a n00b myself.I would recommend just playing around with variables. To call a variable from a form post use $_POST['variablename']; and from the address bar use $_GET['variablename'];. If they are just variables in the script, then you could just use $variablename;. Remember that all php must be in the php tags. When sending variables through links (like in the address bar use http://domain.com/index.php?variablename=variablevalue and when you want to add more vaiables just add & like http://domain.com/index.php?variablename=v...tle=demo&page=2

Link to comment
Share on other sites

Well it all depends on what functionality the company is looking for in their site. My site, for example http://www.oneity-eight.roxr.com , is basically a portfolio of things we do together.Here's how server side scripting (PHP) comes into play on oneity-eight:I use Invision Power Board as our main method of communication. The news column on the homepage is actually reformatted posts from an announcements thread in the forum. Nearly all of IPB's functionality relys on PHP. I even display some basic forum stats on my homepage as well.The biggest advantage of PHP in my opinion is includes. With PHP, I can code small snippets of pages, and set certain conditions to determine which snippet is loaded. Every page on my site is composed of these little snippets as means of a template system. This save me TONS of time and not to mention it reduces file sizes. Think of it like including a link to a CSS file. You can call it from any page. Every page of my site starts as a few empty tables cells. All I do is type in what I want and I'm good to go. The rest of the page components are loaded when somebody actually goes to the page.Another benefit is math functions. My gallery is so easy to add another image. All I have to do is upload a thumbnail and a full size image and the script calculates how many images are to be displayed and where they are to be displayed, the order (alphabetically or by date), and then it templates and puts everything together. I have a full backend of options (I am still adding to this script every day - see this post for EARLY version).As for business:A lot of companies use contact forms. But it really isnt very fun when u fill it out and then it loads outlook express. PHP solves this. It sends the mail itself with no external programs.There are so many things you can use it for, cookies, session data, contact forms, image generation, file uploading, photo galleries, shopping carts, product information, page counters, download systems, message boards, database handling, search engine highlighting, bad word filters, etc... the list goes on and on.For a store locator, you could fill an array of zipcodes as the key's. When the user submits their query, your script searches the array, and finds the key with the zipcode they entered, and returns the value.So when should you use a server side scripting? Personally, I'd say whenever possible, you can achive great things and have a nice integrated site, but, you don't have to use it at all if you don't want to. Hope that answered your question and gave you some ideas:)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...