Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

php and html forms

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

php and html forms

Postby sxrxnnrr » Sun Nov 24, 2002 8:47 am

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
sxrxnnrr
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sun Nov 24, 2002 8:37 am
Location: Colombia

Re: php and html forms

Postby WiZARD » Sun Nov 24, 2002 11:24 pm

sxrxnnrr wrote: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.
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby serg_dz » Mon Nov 25, 2002 12:38 am

If You want to store information in a variable and than print it out, check if you use something like this:

Code: Select all
echo $html_variable;


or better use such structure:

Code: Select all
...
php code
...
?>
...
html code
...
<?
...
php code
...
serg_dz
New php-forum User
New php-forum User
 
Posts: 13
Joined: Thu Oct 10, 2002 10:37 pm
Location: Ukraine

Postby sxrxnnrr » Mon Nov 25, 2002 9:11 am

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.
sxrxnnrr
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sun Nov 24, 2002 8:37 am
Location: Colombia

Postby WiZARD » Mon Nov 25, 2002 11:53 pm

sxrxnnrr wrote: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? :?
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby mynmonic » Tue Nov 26, 2002 4:21 am

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
New php-forum User
New php-forum User
 
Posts: 18
Joined: Tue Nov 26, 2002 3:35 am
Location: Hong Kong

Postby WiZARD » Tue Nov 26, 2002 5:59 am

mynmonic wrote: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...
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby parxal » Tue Nov 26, 2002 6:21 am

In php4 you can't use $yourname, you have to use : $_POST['yourname'];
because global vars are off :)
parxal
New php-forum User
New php-forum User
 
Posts: 40
Joined: Thu Nov 07, 2002 5:58 am

Re: php and html forms

Postby mjr » Tue Nov 26, 2002 8:58 am

sxrxnnrr wrote: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?
mjr
New php-forum User
New php-forum User
 
Posts: 18
Joined: Fri Sep 27, 2002 6:35 am

Postby parxal » Tue Nov 26, 2002 9:38 am

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
New php-forum User
New php-forum User
 
Posts: 40
Joined: Thu Nov 07, 2002 5:58 am

Postby mynmonic » Tue Nov 26, 2002 12:31 pm

parxal wrote: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[] ?
mynmonic
New php-forum User
New php-forum User
 
Posts: 18
Joined: Tue Nov 26, 2002 3:35 am
Location: Hong Kong

Postby parxal » Tue Nov 26, 2002 12:35 pm

it's supose not turn it on, in http://www.php.net they advise to use new php4 methods!
parxal
New php-forum User
New php-forum User
 
Posts: 40
Joined: Thu Nov 07, 2002 5:58 am


Return to PHP coding => General

Who is online

Users browsing this forum: dendonpaul, Google Feedfetcher and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.