Not What You Expected
Form…
…And Function
Operating With Extreme Caution
A Question of Logic
Older But Not Wiser
If Not This, Then What?
Spreading Confusion
The Daily Special
Not What You Expected
In Part One of this series, I gave you a
brief introduction to PHP, and how it fits into your Web application development
environment. I also taught you the basics of PHP variables, and showed you how
to add, multiply and concatenate them together.
Now that you know the basics, it’s time to focus in on one of PHP’s
nicer features – its ability to automatically receive user input from
a Web form and convert it into PHP variables. If you’re used to writing
Perl code to retrieve form values in your CGI scripts, PHP’s simpler
approach is going to make you weep with joy. So get that handkerchief
out, and scroll on down.
Form…
Forms have always been one of quickest and easiest ways to add interactivity to your Web site. A form allows you to ask customers if they like your products, casual visitors for comments on your site, and pretty girls for their phone numbers. And PHP can simplify the task of processing the data generated from a Web-based form substantially, as this first example demonstrates.
This example contains two scripts, one containing an HTML form (named form.htm) and the other containing the form processing logic (message.php). Here’s form.htm:
<html>
<head></head>
<body>
<form action="message.php" method="post">
Enter your message: <input type="text" name="msg" size="30">
<input type="submit" value="Send">
</form>
</body>
</html>
The critical line in this page is the <form> tag
<form action="message.php" method="post">
...
</form>
As you probably already know, the “action” attribute of the
<form> tag specifies the name of the server-side script
(message.php in this case) that will process the information entered
into the form. The “method” attribute specifies how the
information will be passed.
…And Function
Now for the other half of the puzzle: the message.php script. This
script reads the data submitted by the user and “does something with
it”. Here is message.php:
<html>
<head></head>
<body>
<?php
// retrieve form data
$input = $_POST['msg'];
// use it
echo "You said: <i>$input</i>";
?>
</body>
</html>
When you enter some data into form.htm (let’s say “Boo”), and
submit it, the form processor message.php will read it and display it to
you (“You said: Boo“). Thus, whenever a form is submitted to a PHP script,
all variable-value pairs within that form automatically become available for use
within the script, through a special PHP container variable: $_POST.
You can then access the value of the form variable by using its “name” inside the
$_POST container, as I did in the script above.
Obviously, PHP also supports the GET method of form submission. All
you need to do is change the “method” attribute to “get”, and retrieve
values from $_GET instead of $_POST. The
$_GET and $_POST variables are
actually a special type of PHP animal called an array, which I’ll be
teaching you about shortly. Don’t worry too much about it at the
moment, just make sure you’re comfortable with retrieving simple values
from a form with PHP, and then scroll on down to learn about some more
operators that are useful in this context.
Operating With Extreme Caution
Thus far, the scripts we’ve discussed have been pretty dumb. All
they’ve done is add numbers and strings, and read back to you the data
you typed in yourself – not exactly overwhelming. In order to add some
intelligence to your scripts, you need to know how to construct what
geeks call a “conditional statement” – a statement which lets your
script perform one of a series of possible actions based on the result
of a comparison test. And since the basis of a conditional statement is
comparison, you first need to know how to compare two variables and
determine whether they’re identical or different.
You’ve already seen some of PHP’s arithmetic and string operators.
However, the language also comes with operators designed specifically
to compare two values: the so-called “comparison operators”. Here’s an
example that demonstrates them in action:
<?php
/* define some variables */
$mean = 9;
$median = 10;
$mode = 9;
// less-than operator
// returns true if left side is less than right
// returns true here
$result = ($mean < $median);
print "result is $result<br />";
// greater-than operator
// returns true if left side is greater than right
// returns false here
$result = ($mean > $median);
print "result is $result<br />";
// less-than-or-equal-to operator
// returns true if left side is less than or equal to right
// returns false here
$result = ($median <= $mode);
print "result is $result<br />";
// greater-than-or-equal-to operator
// returns true if left side is greater than or equal to right
// returns true here
$result = ($median >= $mode);
print "result is $result<br />";
// equality operator
// returns true if left side is equal to right
// returns true here
$result = ($mean == $mode);
print "result is $result<br />";
// not-equal-to operator
// returns true if left side is not equal to right
// returns false here
$result = ($mean != $mode);
print "result is $result<br />";
// inequality operator
// returns true if left side is not equal to right
// returns false here
$result = ($mean <> $mode);
print "result is $result";
?>
The result of a comparison test is always Boolean: either true (1)
or false (0 – which doesn’t print anything). This makes comparison
operators an indispensable part of your toolkit, as you can use them in
combination with a conditional statement to send a script down any of
its multiple action paths.
PHP 4.0 also introduced a new comparison operator, which
allows you to test both for equality and type: the === operator.
The following example demonstrates it:
<?php
/* define two variables */
$str = '10';
$int = 10;
/* returns true, since both variables contain the same value */
$result = ($str == $int);
print "result is $result<br />";
/* returns false, since the variables are not of the same type even though they have the same value */
$result = ($str === $int);
print "result is $result<br />";
/* returns true, since the variables are the same type and value */
$anotherInt = 10;
$result = ($anotherInt === $int);
print "result is $result";
?>
Read more about PHP’s comparison operators at
http://www.php.net/manual/en/language.operators.comparison.php.
A Question of Logic
In addition to the comparison operators I used so liberally above,
PHP also provides four logical operators, which are designed to group
conditional expressions together. These four operators – logical AND,
logical OR, logical XOR and logical NOT – are illustrated in the following example:
<?php
/* define some variables */
$auth = 1;
$status = 1;
$role = 4;
/* logical AND returns true if all conditions are true */
// returns true
$result = (($auth == 1) && ($status != 0));
print "result is $result<br />";
/* logical OR returns true if any condition is true */
// returns true
$result = (($status == 1) || ($role <= 2));
print "result is $result<br />";
/* logical NOT returns true if the condition is false and vice-versa */
// returns false
$result = !($status == 1);
print "result is $result<br />";
/* logical XOR returns true if either of two conditions are true, or returns false if both conditions are true */
// returns false
$result = (($status == 1) xor ($auth == 1));
print "result is $result<br />";
?>
Logical operators play an important role in building conditional
statements, as they can be used to link together related conditions
simply and elegantly. View more examples of how they can be used at
http://www.php.net/manual/en/language.operators.logical.php.
Older But Not Wiser
Now that you’ve learnt all about comparison and logical operators, I
can teach you about conditional statements. As noted earlier, a
conditional statement allows you to test whether a specific condition
is true or false, and perform different actions on the basis of the
result. In PHP, the simplest form of conditional statement is the if()
statement, which looks something like this:
if (condition) {
do this!
}
The argument to if()is a conditional expression, which evaluates to
either true or false. If the statement evaluates to true, all PHP code
within the curly braces is executed; if it does not, the code within
the curly braces is skipped and the lines following the if() construct
are executed.
Let me show you how the if() statement works by combining it with a
form. In this example, the user is asked to enter his or her age.
<html>
<head></head>
<body>
<form action="ageist.php" method="post">
Enter your age: <input name="age" size="2">
</form>
</body>
</html>
Depending on whether the entered age is above or below 21, a
different message is displayed by the ageist.php script:
<html>
<head></head>
<body>
<?php
// retrieve form data
$age = $_POST['age'];
// check entered value and branch
if ($age >= 21) {
echo 'Come on in, we have alcohol and music awaiting you!';
}
if ($age < 21) {
echo "You're too young for this club, come back when you're a little older";
}
?>
</body>
</html>
If Not This, Then What?
In addition to the if() statement, PHP also offers the if-else
construct, used to define a block of code that gets executed when the
conditional expression in the if() statement evaluates as false.
The if-else construct looks like this:
if (condition) {
do this!
}
else {
do this!
}
This construct can be used to great effect in the last example: we
can combine the two separate if()statements into a single
if-else statement.
<html>
<head></head>
<body>
<?php
// retrieve form data
$age = $_POST['age'];
// check entered value and branch
if ($age >= 21) {
echo 'Come on in, we have alcohol and music awaiting you!';
}
else {
echo "You're too young for this club, come back when you're a little older";
}
?>
</body>
</html>
Spreading Confusion
If the thought of confusing people who read your code makes you feel
warm and tingly, you’re going to love the ternary operator, represented
by a question mark (?). This operator, which lets you make your
conditional statements almost unintelligible, provides shortcut syntax for creating
a single-statement if-else block. So, while you could do this:
<?php
if ($numTries > 10) {
$msg = 'Blocking your account...';
}
else {
$msg = 'Welcome!';
}
?>
You could also do this, which is equivalent (and a lot more fun):
<?php
$msg = $numTries > 10 ? 'Blocking your account...' : 'Welcome!';
?>
PHP also lets you “nest” conditional statements inside each other.
For example, this is perfectly valid PHP code:
<?php
if ($day == 'Thursday') {
if ($time == '0800') {
if ($country == 'UK') {
$meal = 'bacon and eggs';
}
}
}
?>
Another, more elegant way to write the above is with a series of
logical operators:
<?php
if ($day == 'Thursday' && $time == '0800' && $country == 'UK') {
$meal = 'bacon and eggs';
}
?>
The Daily Special
PHP also provides you with a way of handling multiple possibilities:
the if-elseif-else construct. A typical if-elseif-else statement
block would look like this:
if (first condition is true) {
do this!
}
elseif (second condition is true) {
do this!
}
elseif (third condition is true) {
do this!
}
... and so on ...
else {
do this!
}
And here’s an example that demonstrates how to use it:
<html>
<head></head>
<body>
<h2>Today's Special</h2>
<p>
<form method="get" action="cooking.php">
<select name="day">
<option value="1">Monday/Wednesday
<option value="2">Tuesday/Thursday
<option value="3">Friday/Sunday
<option value="4">Saturday
</select>
<input type="submit" value="Send">
</form>
</body>
</html>
As you can see, this is simply a form which allows you to pick a day
of the week. The real work is done by the PHP script cooking.php:
<html>
<head></head>
<body>
<?php
// get form selection
$day = $_GET['day'];
// check value and select appropriate item
if ($day == 1) {
$special = 'Chicken in oyster sauce';
}
elseif ($day == 2) {
$special = 'French onion soup';
}
elseif ($day == 3) {
$special = 'Pork chops with mashed potatoes and green salad';
}
else {
$special = 'Fish and chips';
}
?>
<h2>Today's special is:</h2>
<?php echo $special; ?>
</body>
</html>
In this case, I’ve used the if-elseif-else control structure to
assign a different menu special to each combination of days. Note that
as soon as one of the if() branches within the block is found to be
true, PHP will execute the corresponding code, skip the remaining if()
statements in the block, and jump immediately to the lines following
the entire if-elseif-else block.
And that’s it for now. To view more examples of conditional
statements in action, visit
http://www.php.net/manual/en/language.control-structures.php. In
Part Three, I’ll be bringing you more control
structures, more operators and more strange and wacky scripts – so make sure
you don’t miss it!
Copyright Melonfire, 2004 (http://www.melonfire.com).
All rights reserved.




September 5, 2006 at 2:07 am
This is the first time i have been inspired to leave a comment on a tutorial website.
I happened upon your website today and have yet to explore the whole site,
however, what little i did explore was extremely informative.
I have been searching none stop for the last month for lessons and tutorials for php…
thousands of sites, millions of flashing ads and what little morsels of lessons I did find,
were usually confusing or vague…none of it was sinking in.
I swear, i was about to give up and move on to something else.
THANK YOU SOOOOOO MUCH!
I know my appreciation can’t pay the bills but i just had to leave a message for you.
I truly lucked out today….i found a great website with tons of well written lessons
displayed without the annoying and distracting ads.
PHP is finally sinking in, thanks to your website.
WOW! thank you again!
sincerely,
afsaneh
October 10, 2006 at 8:20 am
Clear, simple, rigorous !
Great.
October 10, 2006 at 10:00 pm
Clear and really helpful. Thanks!
October 16, 2006 at 10:15 am
Yehp, this really is first class teaching… Thanks once again.
October 18, 2006 at 8:36 am
I have been trying to get hold of a decent tutorial. I find that Vivek’s set of tutorials is the best anywhere on the web. Excellent job.
October 18, 2006 at 8:37 am
Ooops! Sorry. I meant to say Vikram’s tutorial!
October 23, 2006 at 3:43 pm
When I copy, paste & run the code from pgs 2 &3, I get the folloowing error mssg.
Notice: PHPDocument3 line 18 – Undefined index: msg
pertinent code snippet follows:
<html>
<head></head>
<body>
<form action="message.php" method="post">
Enter your message: <input type="text" name="msg" size="30">
<input type="submit" value="Send">
</form>
</body>
</html>
<html>
<head></head>
<body>
<?php
// retrieve form data
// next line is line 18
$input = $_POST['msg'];
// use it
echo "You said: <i>$input</i>";
?>
</body>
</html>
//Debug output is "blankmessage.php"
I know it’s something that I am not doing (or doing wrong). BUT is sure is frustrating.
November 8, 2006 at 7:59 pm
like the way you explain things.
I can’t get to part three though.
November 10, 2006 at 12:00 pm
Hi radford0222, I’m a newbie too but decided to see if I could figure out your problem, so here is what I found:
//your code:
<?php
// retrieve form data
// next line is line 18
$input = $_POST['msg'];
// use it
echo "You said: <i>$input</i>";
?>
</body>
</html>
Look at your echo statement, it is not concatenated properly and should read:
echo "You said: "."<i>$input</i>";
/*the whole statement can’t be enclosed in "" but needs to be broken up into two
separate statements divided by the period. It then works just fine. Hope that helps! */
November 10, 2006 at 12:16 pm
Go back to the home page of the tutorial and link to part three from there, I couldn’t get to it from here either.
http://devzone.zend.com/node/view/id/627
December 4, 2006 at 11:14 pm
i’m an intern in my university
I tried to learrn PHP with the help of many tutorials on the net.
but this tutorials for the begginers is really a boon.
very clear and very approachive for a begginer
December 23, 2006 at 7:33 pm
radford0222,
It’s been a while since you posted, but I thought I’d post some suggestions in case anyone else encounters the same problem. I believe the error is because you have all the code you posted in a single file. This actually needs to be split into two files as described in part 2 of this tutorial:
<html>
<head></head>
<body>
<form action="message.php" method="post">
Enter your message: <input type="text" name="msg" size="30">
<input type="submit" value="Send">
</form>
</body>
</html>
This above part should be saved to a file named "form.html"
<html>
<head></head>
<body>
<?php
// retrieve form data
// next line is line 18
$input = $_POST['msg'];
// use it
echo "You said: <i>$input</i>";
?>
</body>
</html>
And this part should be saved in a file named "message.php". To use this PHP program, you should open "forms.html" in your webbrowser, enter text into the text box, and click Send. You should NOT open "message.php" directly or you will get the error message that radford describes above.
March 16, 2007 at 11:50 am
Hey,I just wanted to say thanks a lot, this tut is really great, your style in explaining is very easy to follow and remember and your examples are very instructive and you’re funny
That was about all I wanted to say, once again thanks Ella
April 12, 2007 at 7:25 am
This is great. Even for programmers with good coding experience in other languages will find the tutorials exciting. I encourage you to keep it up. For PHP developers, the sky is not the limit, PHP is!
May 9, 2007 at 10:56 am
such a wonderfull tutorial
June 21, 2007 at 11:33 am
Hello..
This is a very well organized and interesting set of php tutorials.. I will say one amongst the best out there..
Good job man!
Yours,
Wakish
(http://wakish.info/)
June 21, 2007 at 11:35 am
Hello..
This is a very well organized and interesting set of php tutorials.. I will say one amongst the best out there..
Good job man!
Yours,
Wakish
(http://wakish.info/)
August 13, 2007 at 6:31 pm
Is there any difference between <> and !=?
September 8, 2007 at 10:29 pm
Dear Vikram,
Green salad with pork chops & mashed potatoes would be yucky unless 1) cooked (spinach?), or 2) served on a separate plate, and the latter would only be palatable if served b e f o r e the main course.
I agree with the other recent post’er (read: person posting a comment) that this site is a breath of fresh air compared to about 99.99% of such sites out there, and the difference lies in the fact that you are not afraid of the generous use of words to explain what it is that you are doing. Lots of such sites just throw a lot of gobbeldygook code at you, expecting you to be interested enough to be willing to torture yourself enough to wade through said gobbeldygook in order to figure out what the devil is going on. Also, in taking the trouble to explain things, the author is thereby more or less obliged to organize his thoughts/"utterances", which translates to even greater added value!
I w i l l be back!
Yours
phileasphogg
October 21, 2007 at 2:29 pm
I love your tutorial! I am at Charter Communications and taking the course while dealing with customers and I find this one of the best I have ever seen. I have some experience in coding c++, java, javascript, html, ect. But noone does it like you! Great work!
October 23, 2007 at 11:32 pm
Hi, in this example, "$special" can open php pages? What I want is to make the description of a number of products all in a page that called products.php. so the description of products would be: products?cat=1 for the first product and so on.
thank you.
<html>
<head></head><body>
<?php
// get form selection
$day = $_GET['day'];
// check value and select appropriate item
if ($day == 1) {
$special = ‘Chicken in oyster sauce’;
}
elseif ($day == 2) {
$special = ‘French onion soup’;
}
elseif ($day == 3) {
$special = ‘Pork chops with mashed potatoes and green salad’;
}
else {
$special = ‘Fish and chips’;
}
?>
<h2>Today’s special is:</h2>
<?php echo $special; ?>
</body>
</html>
October 29, 2007 at 12:12 am
I am a newbie to PHP, I am learning here, thank you very much! Im planning to migrate my systems to PHP, one of the things I want to know is calculations of time, how do you that in PHP? Thanks!
November 1, 2007 at 2:44 pm
Well, guess it was a waste of buying this stupid 30 euro book.. This tutorial totally rocks the book! I am actually finding this very interesting.
Thanks for the great tutorial. PHP5, here I come!
November 17, 2007 at 3:47 am
It’s a comprehensive tutorial for the newbies to grasp PHP.
December 13, 2007 at 11:20 pm
Terrifically helpful stuff. Thanks much for doing this — it’s a real service!!!
On to lesson 3.
December 30, 2007 at 1:19 pm
I never came up against an easy explanation such as yours! thank you for making it so easy!
January 2, 2008 at 7:36 pm
for parts 2 and 3, i have copied the code exactly:
<html>
<head></head>
<body>
<form action="message.php" method="post">
Enter your message: <input type="text" name="msg" size="30">
<input type="submit" value="Send">
</form>
</body>
</html>
and put this in a file called "testpage.html"
<html>
<head></head>
<body>
<?php
// retrieve form data
$input = $_POST['msg'];
// use it
echo "You said: <i>$input</i>";
?>
</body>
</html>
and put this in a file called "message.php"
the form displays OK, but when I hit "send" all that is returned is a blank page with: $input"; ?> in the top left.
Can anyone help?
Thanks!
January 17, 2008 at 2:10 am
This is a wonderful website! I cannot stop reading it.
I’ve never found learning a new programming language so enjoyable!
THANK YOU SO MUCH!!!
January 21, 2008 at 8:38 am
Bravo! Excellent!
One question,if i may.How to put html doc.(thanks.html)in
php?
if (condition) {
do /*(this!=go and display thanks.html ?????)*/
}
else {
do this!
}
February 5, 2008 at 1:40 pm
I’m a self taught hack that does web sites for local social clubs that I belong to. I don’t get any money for my efforts but it’s hard to buy a drink when I stop in. hehe
I have been to a bunch of places on the net and bought books that left me scratching my head. I’m only through the second lesson so far and I’m already able to grasp virtually everying you’ve taught.
Thanks for much for a wonderful site.
Jim R.
February 14, 2008 at 6:01 am
i’m a novice user of php, actually, im not yet in manual, thank you so much, your page is vvery helpful, more power… happy valentines..
March 11, 2008 at 11:37 pm
im a uni studant and ive been struggling with this stuff for about 2 months, im going through your stuff and its actualy starting to make sense!
THANKYOUS!
April 26, 2008 at 8:23 pm
Hi, I copied the code for ageist.php and the form and I am getting this error
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /Library/WebServer/Documents/ageist.php on line 8…
I am new at this although I didn’t change the code…any help would be appreciated…
May 12, 2008 at 3:17 pm
Just a quick note to thankyou for these well written tutorial’s. You definately get the impression that the author has a clear undertstanding of php and explains things in a a very down to earth and clear manner.
Brilliant!
May 12, 2008 at 3:17 pm
Just a quick note to thankyou for these well written tutorial’s. You definately get the impression that the author has a clear undertstanding of php and explains things in a a very down to earth and clear manner.
Brilliant!
June 8, 2008 at 10:47 am
<php?
$a = ‘Thanks! Now I can make my website better with php!’
echo $a
?>
June 11, 2008 at 3:30 pm
I read it 3 years ago
I read it last yeat
Am reading it now.
I dont do much with php but anytime I have a challenge I come right back.
$Q = ‘conguraturation’;
$Q .= ‘s’;
echo $Q;
Q now contains "conguraturations"
June 27, 2008 at 11:19 pm
I’m having the same issue as James above, but since no one helped him out, I figured I’d ask again.
The form displays OK, but when I hit "send" all that is returned is a blank page with: $input"; ?> in the top left.
Any ideas?
June 30, 2008 at 9:38 pm
To the people getting the
$input"; ?>
output error.
Check your opening <?php TAG in your ‘message.php’ file.
I’m just a newbie too, but it looks like the page isn’t reading php code, its trying to just display as standard html.
September 18, 2008 at 5:39 pm
I was getting either a blank screen or sometimes an input error. I found my problem was when I started form.htm. I was double clicking
on the file name and seeing this in the address window of my browser:
D:\wamp\www\Tests\form.htm and after clicking on ‘submit’
D:\wamp\www\Tests\message.php and a blank screen.
My fix instead to type into the browser window: (I using a subfolder ‘test’ for these files.
http://localhost/Tests/form.htm and after clicking on ‘submit’
http://localhost/Tests/message.php and it worked.
October 3, 2008 at 5:14 pm
I too have been trying to find a way into PHP – these tutorials are exactly what I needed and I’m hugely grateful to you for providing them.
THANK YOU
October 23, 2008 at 4:38 am
I’m hurrying to try to learn PHP by a deadline and was wondering if someone can help me.
The first part of this tutorial involving the "echo ‘You said’"… works just fine when I make a separate html and php file.
I ran into trouble with the next part of the tutorial with the entering age into a textbox and having it give you one of the two responses. I could paste my code here, but it’s exactly the same as the code in the tut.
File name: ageist.html
<html>
<head></head>
<body>
<form action="ageist.php" method="post">
Enter your age: <input name="age" size="2">
</form>
</body>
</html>
File name: ageist.php
<html>
<head></head>
<body>
<?php
// retrieve form data
$age = $_POST['age'];
// check entered value and branch
if ($age >= 21) {
echo ‘Come on in, we have alcohol and music awaiting you!’;
}
if ($age < 21) {
echo "You’re too young for this club, come back when you’re a little older";
}
?>
</body>
</html>
When I preview the HTML in a browser, I get the HTML page I wanted, enter a number into the age, tried all numbers, and no matter what I get an error page saying:
Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
If you think this is a server error, please contact the webmaster.
I’m using XAmpp and its PHP version 5.2.6
I’ve also tried adding a submit button to the ageist.html, and I get the same result.
I get the same error message when trying the next php/html files involving the days of the week.
I would really appreciate if anyone will be able to help me, thanks.
December 1, 2008 at 7:47 am
Hi guys:
Im totaly new at PHP and so far this site is being very helpfull, However it seem a lot of users are getting the same error when trying to use the example code . and doug some answers have being posted , the havent resolved the problem. Im having the same problem (geting a blank page as response. Some one sugested to use a period to cocatenate that dint work eather. Does anybody have this working properly ? I like the explanations they are very clear but if the code dosnt work is hard to advance. I copy and pasted the code to the two baned files and they are bouth on the same dir on the apache server path.
THANKS IN ADVANCE FOR ANY HELP
MIKE
December 3, 2008 at 2:12 am
Hi guys:
I’m also a newbie with a quest, and after a little research I found the answer to this mystery.
I’m sure all of us getting this error are running on a single machine. In other words you installed Apache, MYSQL and PHP on your Windows XP box for testing purposes.
Well if you double click on the "forms.htm" or "ageform.htm" the browser will open this on Windows not on Apache so therefore you will get a blank page in return when you submit.
Now if you type in "localhost\forms" or "localhost\ageform" on the browser you will be submitting to Apache server to parse and in return you will get the correct result. There is nothing wrong with the code.
Remember every time you want to run something on the server you must enter it as "localhost\whatever you are running" and there wont be any errors.
By the way however the ageform.htm is missing the submit line so copy it from the forms.htm and you should be fine.
"is the stiring that makes tea sweet"
Mike
January 14, 2009 at 3:09 am
This tutorial is seriously so great. Thank you so much for putting in the time to make it. Really, I can’t say enough. This tutorial is exactly what I’m looking for!
February 17, 2009 at 2:33 pm
This is a fantastic tutorial……. can’t help be feel hungry after the last one…..
if ($day == 1) {
$special = ‘Chicken in oyster sauce’;
}
elseif ($day == 2) {
$special = ‘French onion soup’;
}
elseif ($day == 3) {
$special = ‘Pork chops with mashed potatoes and green salad’;
}
else {
$special = ‘Fish and chips with French onion soup and Pork chops with mashed potatoes…..’;
Every day is Saturday for me…. yum yum yum!!
March 16, 2009 at 1:32 pm
For those getting the message:
$input"; ?>
I have the exact same problem. I use phpDesigner. Although executing and testing php files work perfectly fine, as soon as I try to include a php file in to an HTML file it doesn’t seem to work. In phpDesigner, I get the ability to "download" the php file. In Firefox I just get the message above.
This means we need to install Apache… sigh. I was hoping phpDesigner already had the PHP fully supported.
September 20, 2009 at 2:53 pm
Hi,
First of all……..A big thanks to you for dedicating so much of time for creating these invaluable tutorials.
These are really helpful for the beginners and will go a long way in helping them to learning in a FUN and interactive way.
Keep it up esp the FUNNY interactive way.
December 24, 2009 at 4:33 pm
Your tutorial series is one of the best I have seen in a long time. All tutorial writers should use your series as model to follow, especially concerning in the detail and clarity you have explained things.
February 19, 2010 at 1:43 am
I’ve registered just to thank You for the wonderfully written and fun tutorial. All the others I came across were boring and unclear, as well as the lectures on php I attended. Luckily, I came across <?or was it something more than luck?> this one.
June 7, 2010 at 7:24 pm
the last example is not working…….
the example of day..and cooking.php
the "get" function….plzz….help …
thanx 4r this fantastic script…..dude..
August 8, 2010 at 11:16 am
DHUAR TUING TUING BLETAK BLITUK WEW WOW HEHEU
January 10, 2011 at 7:05 pm
Been trying to get to a practical tutorial and have eventually found it here. The last such stuff was Alan Simpson with Dbase. Currently am using Access on Mysql and need to migrate to PHP. The cut paste and modify wasn’t getting me there I hope this will.
Is there a book on PHP as written by afore mentioned Mr A Simpson on Dbase III- a walk through practical examples? if so some kindly soul point me to that- Please.
March 2, 2011 at 1:17 am
How simple everything is explained in an easy comprehensible form.
Great tutorial.
May 7, 2011 at 8:09 pm
Simple, straight on the subject(no yada yada), clear. Perfect!
Can I say I love you ? XD
August 25, 2011 at 9:08 am
I am an absolute beginner… This has me excited and inspired to do amazing things… Thank you!