Subject: Code not working well
Posted By: vinish Post Date: 11/11/2005 4:45:39 PM
Hi Everyone,

I've just gotten Beginning PHP 4 book and need some help. I tried running the code they have on Page 120 and it does'nt quite work too well on IE.

The HTML file works just fine, but the .php file does'nt return anything. Thank you.

PHP version : 4.3.4
Browser: IE

Here is the code for car.html and car.php
Car.html
<B>Namlu Car Rentals</B>
<FORM METHOD=POST ACTION="car.php">
First Name:
<INPUT NAME="First Name" TYPE="TEXT">
Last Name:
<INPUT NAME="Last Name" TYPE="TEXT">
Age:
<INPUT NAME="Age" TYPE="TEXT" SIZE="3">
<BR>
<BR>
Address:
<TEXTAREA NAME ="Address" ROWS="4" COLS="40">
</TEXTAREA>
<BR>
<BR>
"Do you hold currently a driving license?"
<INPUT NAME="License" TYPE="Checkbox">
<BR>
<BR>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>

Car.php
<?php

if ($Age>20 && $License=="on") echo ("Good to go");
if ($Age>21 && $License=="") echo ("Sorry.. ");
?>

Reply By: foddie Reply Date: 11/11/2005 5:54:59 PM
Hi

The short answer is try your php code like this:

<?php

if ($_POST['Age']>20 && $_POST['License']=="on") echo ("Good to go");
if ($_POST['Age']>21 && $_POST['License']=="") echo ("Sorry.. ");
?>

As a variable POSTed from the form is accessed as $_POST['whatever'], and to extract it from an url use the get method $_GET['whatever'], there is lot of explanations why, do a google search from doing a search using keywords: "register_globals" or search the forums here for reasoning behind it.

HTH
David
Reply By: vinish Reply Date: 11/11/2005 7:02:46 PM
Thank you very much for this.

It works just fine.


Go to topic 10974

Return to index page 437
Return to index page 436
Return to index page 435
Return to index page 434
Return to index page 433
Return to index page 432
Return to index page 431
Return to index page 430
Return to index page 429
Return to index page 428