dry fit polo shirts Writing Your First PHP Script

tall polo shirts Writing Your First PHP Script

I have always believed that the most fun way to learn a new programming language (whether it is a language like C or a scripting language like PHP), is to use it to write a real life useful program. Of course this is not the most systematic method of learning, but it works well if you already have some background in programming. This type of form is sometimes referred to as a FormMail or Form to Mail script. In later articles, I will probably develop that script (and others) to include features commonly found in such FormMail scripts.

I will have to assume that you have some knowledge of HTML code, otherwise this tutorial will wind up being tediously long. If you need help with HTML coding, you might try the beginner’s guide at:For those who are programming savvy, this is sort of like a “Hello World” program, but infinitely more useful!

WRITING THE FEEDBACK FORMThe first thing we need to do is to write the feedback form itself. This is made extremely easy by the facilities available in PHP. Do not put anything else into that file, ie, don’t put in any other HTML tags or headers, etc. Likewise the contents of the “message” field is put into the variable $message.

All the script has to do is to call a special function appropriately called “mail” which would do the actual sending of the email. The first parameter to mail is actually the email address you want the form contents to be sent to, ie, your own email address. The second parameter is the “Subject” of the email message. The last two parameters are the content of the message and any other headers you want sent, respectively. We want a “From” header so that we know who is sending the email to us and can reply to him/her if we need to.

Notice that, like many other programming languages, strings (sequences of characters) are enclosed in double quotes, such as “Feedback Form Results”.

Variables like $message can be used as is.

You can also use single quotes (like ‘Hi there’) to quote strings, but when you do so, the variables included are not expanded.

Finally, it is appropriate to thank the visitor for his message. The “header” function allows us to send any HTTP header to the browser.

By the way, the script has to be enclosed within the “” tags because the PHP processor treats all input as HTML code unless otherwise specified. On some systems, you may need to use “” as the opening and closing tags to get the script to work.

Easy wasn’t it? In just a few lines, you’ve written your first PHP script. And it’s not some trivial and useless script it is actually a working, usable program!
dry fit polo shirts Writing Your First PHP Script