register_globals workaround problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
greeneel
Forum Commoner
Posts: 47
Joined: Wed Jul 30, 2003 5:19 pm

register_globals workaround problems

Post by greeneel »

mod edit: added CODE and PHP tags

hello all

I recently installed PHP on my XP pro and my Win 2000 server systems.

I know nothing about php, 0% and i`m having a big problem . the book i`m using is PHP and Mysql Web Development. the book came with a CD that i`m using also and apache and php binaries and various sources..
I didn`t use the binaries that came with teh book. I downloaded php 4.3.2 and apache2 for XP and apache 1.3.9 i think i installed apache 2 on XP and apache 1.3.9 i think it was on the Win2000 server system....
now everything works i created the <? phpinfo() ?> and the the info page..

Now as I was goin tru this book i came across this:

Code: Select all

&lt;form action="processorder.php" method=post&gt;
&lt;table border=0&gt;
&lt;tr bgcolor=#cccccc&gt;
 &lt;td width=150&gt;Item&lt;/td&gt;
 &lt;td width=15&gt;Quantity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Tires&lt;/td&gt;
 &lt;td align=center&gt;&lt;input type="text" name="tireqty" size=3 
maxlength=3&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Oil&lt;/td&gt;
 &lt;td align=center&gt;&lt;input type="text" name="oilqty" size=3 maxlength=3&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;
 &lt;td&gt;Spark Plugs&lt;/td&gt;
 &lt;td align=center&gt;&lt;input type="text" name="sparkqty" size=3 
maxlength=3&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td colspan=2 align=center&gt;&lt;input type=submit value="Submit Order"&gt;&lt;/td&gt; &lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
Now the following script is what the book gave me for for the actual processorder.php page which is the output page or the page that was called by the form page that the <form action="processorder.php" method=post>calls when u fillout the form and submit it i typed it in exactly as the book gave it...

Code: Select all

<html>
<head>
 <title>Bobs Auto parts</title>
</head>
<body>
<h1>Bobs Auto Parts</h1>
<h2>Order Results</h2>
<?
   echo "<p>Order processed.";
   echo date("H:i, jS F");
   echo "<br>";     
    echo "<p>Your order is as follows:";
   echo "<br>";
   echo $tireqty." tires<br>";
   echo $oilqty." bottles of oil<br>";
   echo $sparkqty." spark plugs<br>";
?>

</body>
</html>

i`m newbie but i figure that on the page that has the form and numbers are typed in the quantity field for the amounts or whatever the individual wants and you should be able to see these once u submit it and the output page comes up..I am not getting anything all i`m seeing is:

Bobs Auto Parts

Order results

Your order is as follows:

tires
bottles of oil
spark plugs

but as u can see they are no amounts infront of tire, bottles of oil or
spark plugs and i typed the number 2 in all three fields but it wasn`t echoed to the output page..

I tried it on the XP Pro OS system running php 4.3.2 and apache2
& on a windows 2000 server OS running php 4.3.2 and apache 1.3.9 ..

I have since found out that this was something to do with register_globals bein off, but i turned it on and later found out that its off by default and its that way because of security reasons.. is there a work around for this?

remember i know nothing about php so could u explain so that i could understant it please....also i want to continue is the book any good? was it incorrect in anyway

I neeed Help ..would like to learn php....it suxs bein stuck and i haven`t even begun building anything yet..
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

This isn't really something for the advanced forum - and certainly not a sticky thread.

See viewtopic.php?t=511
Last edited by McGruff on Thu Aug 14, 2003 9:22 pm, edited 1 time in total.
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post by qartis »

Replace processorder.php with this:

Code: Select all

<html> 
 <head> 
 <title>Bobs Auto parts</title> 
 </head> 
 <body> 
 <h1>Bobs Auto Parts</h1> 
 <h2>Order Results</h2> 
 <? 
 echo "<p>Order processed."; 
 echo date("H:i, jS F"); 
 echo "<br>"; 
 echo "<p>Your order is as follows:"; 
 echo "<br>"; 
 echo $_POST['tireqty']." tires<br>"; 
 echo $_POST['oilqty']." bottles of oil<br>"; 
 echo $_POST['sparkqty']." spark plugs<br>"; 
 ?> 
 
 </body> 
 </html>
User avatar
greeneel
Forum Commoner
Posts: 47
Joined: Wed Jul 30, 2003 5:19 pm

Post by greeneel »

Hey qartis , I coppied and pasted your code but it didn`t work for some reason ..please advise

thx
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post by qartis »

Instead of $_POST, try $HTTP_POST_VARS
User avatar
greeneel
Forum Commoner
Posts: 47
Joined: Wed Jul 30, 2003 5:19 pm

Post by greeneel »

hey qartis is it

example

echo $HTTP_POST_VARS['tireqty']." tires<br>";
User avatar
greeneel
Forum Commoner
Posts: 47
Joined: Wed Jul 30, 2003 5:19 pm

Post by greeneel »

ok I tried it and it worked man

Thanks alot...now i can move on lol
Post Reply