LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-22-2004, 01:18 PM   #1
Booster
Member
 
Registered: Sep 2003
Location: Ontario, Canada
Distribution: Gentoo, Suse
Posts: 59

Rep: Reputation: 15
Simple PHP form not working...


I'm having an odd little php problem... I just installed PHP and Apache2 on a second Linux box, and everything seemed to be working fine (ie: phpnuke works flawlessly), but when I put a calculator script on it, it didn't work (It did work on my other Linux webserver). I made a VERY simple script to just take a couple inputs and output a result, but it fails - the variables are not being passed back to the script after the HTML submit.

Here's the simple script:

PHP Code:
<HTML>
<HEAD><TITLE>Simple Script</TITLE>
<BODY><?php
echo "<B>voltage calc</B>";
echo 
"<P><P>";
echo 
"Enter the following info:<P>";
echo 
"<FORM METHOD=\"POST\" ACTION=\"$PHP_SELF\">";
echo 
"<BR>resistance:<INPUT NAME=\"r\" TYPE=\"text\">";
echo 
"<BR>current:<INPUT NAME=\"i\" TYPE=\"text\">";
echo 
"<P><INPUT TYPE=\"submit\" name=\"submit\" value=\"Calculate!\"></FORM>";
echo 
"<P>Submit: $submit  r=$r   i=$i";   // dump out the vars

if($submit)
{
$result $i*$r;
echo 
"Result is: $result";
}
?></BODY><HTML>
Again, this script works on one machine (Apache/2.0.44 (Unix) PHP/4.3.3), but not on the other (Apache/2.0.48 (Gentoo/Linux) PHP/4.3.4 ). The script "runs", but it is simply not getting the variables.

Any thoughts?

Thanks
 
Old 02-22-2004, 02:01 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
It sounds like you have left "register globals" off in php.ini, the scripts you are trying to run probably require them to be turned on.
 
Old 02-22-2004, 02:59 PM   #3
Booster
Member
 
Registered: Sep 2003
Location: Ontario, Canada
Distribution: Gentoo, Suse
Posts: 59

Original Poster
Rep: Reputation: 15
Thanks David - that did it. As soon as I saw your post I knew it would (been down this road before
 
Old 02-23-2004, 04:29 AM   #4
AMMullan
Member
 
Registered: Sep 2003
Location: United Kingdom
Distribution: Ubuntu, Arch
Posts: 438

Rep: Reputation: 30
Is it safe to register_globals on? For some reason I thought it wasn't...
 
Old 02-23-2004, 02:50 PM   #5
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
It is slightly less secure but if you do proper error checking in your scripts it should be fairly safe.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP MySQL Support not working (Hopefully simple question) icarusfall Linux - Software 5 11-08-2005 10:30 AM
PHP form help Zeppelin_Fan Programming 5 03-24-2005 04:47 PM
Simple PHP help with a form :-) 2782d4 Programming 3 12-17-2004 02:53 AM
Simple php script with html form not working. sinsoush Programming 4 04-01-2004 08:02 PM
php/form kev82 Programming 0 02-25-2004 06:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration