php and html forms

A

Anonymous

Guest
sxrxnnrr said:
i cant get to work a simple html form with php...
i can't see any of the information introduced in the html form...it just shows an empty page
Actually you have a some mistake in httpd.conf or in script...
Give me more info.
 
If You want to store information in a variable and than print it out, check if you use something like this:

Code:
echo $html_variable;

or better use such structure:

Code:
...
php code
...
?>
...
html code
...
<?
...
php code
...
 
sxrxnnrr said:
these were the only changes i made to the httpd.conf file

ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .htm
AddType application/x-httpd-php .html
AddType application/x-httpd-php .phtml
Action application/x-httpd-php "/php/php.exe"

when i execute phpinfo(); it works fine but i can't get to pass a variable from a html form to use it in any other place.
That's all what you change in httpd.conf?
How about cgi.force_redirect = 1? :?
 
I have checked this forum and I found that many people here have the same problem as mine, that I cannot retrieve the variable content to php script from html form. This is a simple sample I copy from my beginner's book, and it's just don't work in my LAMP:

<html>
<body>
<form action="thisfile.php" method="GET">
<p>Give your name: <input type="text" name="yourname">
<br><input type="submit" name="Submit">
</form>
<?php

print("$yourname\n");
?>
</body>
</html>


very simple isn't it? but the $yourname inside the php tags can just never get the value of the yourname that I type in the text box, it's empty.
I noticed that this seems work in php3 but not php4 right? So how is the correct way to do this? even my php4 begineer book is teaching the wrong thing :(
 
mynmonic said:
I have checked this forum and I found that many people here have the same problem as mine, that I cannot retrieve the variable content to php script from html form. This is a simple sample I copy from my beginner's book, and it's just don't work in my LAMP:

<html>
<body>
<form action="thisfile.php" method="GET">
<p>Give your name: <input type="text" name="yourname">
<br><input type="submit" name="Submit">
</form>
<?php

print("$yourname\n");
?>
</body>
</html>


very simple isn't it? but the $yourname inside the php tags can just never get the value of the yourname that I type in the text box, it's empty.
I noticed that this seems work in php3 but not php4 right? So how is the correct way to do this? even my php4 begineer book is teaching the wrong thing :(
check php.ini
find this string:
register_globals = Off and change at register_globals = On
at your place i'm install PHP as ISAPI module not like CGI...
 
In php4 you can't use $yourname, you have to use : $_POST['yourname'];
because global vars are off :)
 
sxrxnnrr said:
i cant get to work a simple html form with php...
i can't see any of the information introduced in the html form...it just shows an empty page
can you give a sample of code u use?
 
make a html file with:

<form name="form1" method="post" action="enviar.php">
<p>Name :
<input type="text" size=40 name="name">
</p>
<input type="submit" name="submit" value="Enter information">
</form>

This will create a form with a textbox named name

make a php file named enviar.php with :

<?
$name=$_POST['name'];
printf("the name is". $name);
?>

this will print the name that tou put in the textbox.
 
parxal said:
In php4 you can't use $yourname, you have to use : $_POST['yourname'];
because global vars are off :)

What's the point for php4 to turn the register_globals off? Security?
I m supposed to turn it on or use $_POST[] ?
 
it's supose not turn it on, in http://www.php.net they advise to use new php4 methods!
 
Back
Top