Click to See Complete Forum and Search --> : a prob with php and form's


abraxas@debian
11-18-2002, 12:39 PM
ok, my prob:

on my pc, i've got an apache server (1.3.26) with dynamic php support (php 4.2.3). to explain my problem just look an the following code:

<form name="formular1" action="formular1.php" method="get">
Quadrieren:<input type=text name=zahl></input><br><br>
<input type=submit name=rechnen value=ausrechnen></input>
</form>

<?php
if($rechnen){
$quadrat=$zahl*$zahl;
echo "Das Quadrat ist <b><font color=#0020FF>$quadrat</font></b>";
}
?>

yes, it's in german *gg*. the problem is that php can't access the variable "rechnen" from the form.
the script sould work at all. "rechnen" has "ausrechnen" as a string-value so i don't know why php can't use it. other php-scripts with no form content works well.

that's very bad and i'm glad about every idea ;-)).
I think it has somethink to do with the php.ini (the php-options file)

ok, i count on you *gg*, abraxas

Copyright: This code was taken from the book "Dynamische Webseiten mit PHP" by Jochen Franke http://www.jochen-franke.de/

The_Don
11-18-2002, 01:47 PM
change method="get" to method="post"

abraxas@debian
11-18-2002, 02:04 PM
sorry, but it isn't so easy *gg*.
but be sure, i've tried the get-post change *gg*. the same, php can't access the form.

the same script works with an apache installation with php cgi-implementation under windows *gg*.

but php-developing under windows with apache?? sounds strange ;-)))

but thx for your reply, any more ideas???

greez, abraxas

Stuka
11-18-2002, 03:39 PM
Have you tried echoing the value of $rechnen? It seems to me that you should get it handily - I've used the same technique on Windows and FreeBSD using PHP, with a default php.ini.

patas75
11-19-2002, 01:34 AM
I'm experiencing the same issue. I have apache 2 with php 4.2.3 and when I have a form that has a submit button, the variables are not being access from the php script. I have looked at the php.ini but could not see anything relating to forms. Any ideas?

patas75
11-19-2002, 02:15 AM
I think I found an answer for you. If you have global_registers off in php.ini, you will not be able to use the variable name. Instead you have to use $_POST["itemname"] to get the value of the form item. Here is a tutorial on forms that explains this: http://www.php.net/manual/en/tutorial.forms.php.

Patas

Rüpel
11-19-2002, 03:24 AM
Originally posted by patas75
I think I found an answer for you.

this definitely is the answer ;)

abraxas@debian
11-22-2002, 11:24 AM
BIG THX FOR YOUR HELP!!!

Yes, the "register_globals" was the needed option. When it's set to "On" all works fine.

There is something written about security problems with this option. Does anyone know what this could meens?

Greez, abraxas

Rüpel
11-22-2002, 12:34 PM
kauf dir mal die c't von letzter woche, da is ein guter artikel darüber drin.

i told him to buy a computer magazine (available here in germany), where there is an article on this issue