Jump to content

Reliability of tutorials


Klauwaart

Recommended Posts

In another post here, where I asked for proper PHP learning resources, I mentioned how unreliable some tutorials can be.

 

I started doing a project from a tutorial site, and copied all the code word for word, as follows:

 

processorder.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<!--  Created with the CoffeeCup HTML Editor 2007  -->
<!--           http://www.coffeecup.com/           -->
<!--         Brewed on 13/10/2007 17:50:47         -->
<head>
  <title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?
echo ("<p>Order processed at ");
echo date("H:i, jS F");
echo ("<br>");
echo ("<p>Your order is as follows: ");
echo ("<br>");
echo "$tyreqty tyres<br>";
echo "$oilqty bottles of oil<br>";
echo "$sparkqty spark plugs<br>";
?>
</body>
</html>

 

and

 

form.htm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<!--  Created with the CoffeeCup HTML Editor 2007  -->
<!--           http://www.coffeecup.com/           -->
<!--         Brewed on 13/10/2007 17:15:03         -->
<head>
  <title></title>
</head>
<body>
<form action="processorder.php" method=post>
<table border=0>
<tr bgcolor="#cccccc">
  <td width="150"Item</td>
  <td width="15"Quantity</td>
</tr>
<tr>
  <td>Tyres </td>
  <td align="center"><input type="text" name="tyreqty" size=3 maxlength=3></td>
</tr>
<tr>
<td>Oil </td>
<td align="center"><input type="text" name="oilqty" size=3 maxlength=3></td>
</tr>
<tr>
  <td>Spark Plugs </td>
  <td align="center"><input type="text" name="sparkqty" size=3 maxlength=3></td>
</tr>
<tr>
<td colspan=2 align="center"><input type="submit" value="Submit order"></td>
</tr>
</table>
</form>

</body>
</html>

 

I then uploaded both pages and filled in the form, believe it or not, I get no errors, everything comes up as it should, except the values I entered in the form.

Does anyone know where the fault lies?

And, if that is from a tutorial, it seems they are certainly teaching people how not to do it.

Thanks in advance for any help I might get.

 

Link to comment
https://forums.phpfreaks.com/topic/73881-reliability-of-tutorials/
Share on other sites

And, if that is from a tutorial, it seems they are certainly teaching people how not to do it.

 

More than likely its just an outdated tutorial. Vairables posted via a form use to just magically appear because of a setting called 'register_globals' which use to be on by default. However, register_globals is a security risk (should have never existed in the first place IMO) and is now off by default. The variables you seak can be found within the $_POST[] array. eg;

 

<?php

  // use
  $_POST['sparkqty'];

  // instead of
  $sparkqty;

?>

 

ps: That tutorial looks a bit dodgy anyway. The echo language construct does not need (and never did) brackets around its arguments.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.