heres the thing
i just installed php and apache on my linux box
i finally got php working actually
i am just starting to learn php
but i got this from tutorial
my first page is this
#test.php
<html>
<head>
<title>My Form</title>
</head>
<body>
<form action="test2.php" method=post>
<input type="text" name=data>
<input type=submit value=enter>
</form>
</body>
</html>
the second page
#test2.php
<html>
<head>
<?php
print $data;
print ("this should return your entered data");
?>
</body>
</html>
no i ran both pages
so i know php works
cuz the second one does display
"this should return your entered data"
but it doesn't display what i entered in the box....
i don't know if i configured something wrong in my php setup prosses
cuz it won't return the dataWelcome to the forums.This should really be in the PHP subforum.It looks to me like register globals is disabled on your server(this is a good thing),so in the page that displays what you submitted with the form..change:
echo $data;
to
echo $_POST["data"];that worked thanks
and how do i enable the register globals
any why is that a good thing to have them disabled?In php.ini...there is an option...register_globals...set it to on to enable them,or in httpd.conf you can put php_flag register_globals on .Having them disables increases security in your scripts...for example....with your previous code:
echo $data;
and register globals on...that variable could come from ANY request method/variable out of GET,POST,COOKIE,SERVER and ENVIRONMENT.Obviously you know the data should come from a POST method form...however,using just $data means I could:
Use the query string(ie: page.php?data=whateverIwant),which is the GET method
Use your form,which is the POST method
Have a cookie named data from your site with a value in it
If none of those are set,you may get one of the predefined SERVER or ENVIRONMENT variables
this is a big security hole and really doesn't make a few characters difference typing worth it.You can use:
$data = $_POST["data"];
if you need to use it in multiple places you can from then on just echo $data;
i just installed php and apache on my linux box
i finally got php working actually
i am just starting to learn php
but i got this from tutorial
my first page is this
#test.php
<html>
<head>
<title>My Form</title>
</head>
<body>
<form action="test2.php" method=post>
<input type="text" name=data>
<input type=submit value=enter>
</form>
</body>
</html>
the second page
#test2.php
<html>
<head>
<?php
print $data;
print ("this should return your entered data");
?>
</body>
</html>
no i ran both pages
so i know php works
cuz the second one does display
"this should return your entered data"
but it doesn't display what i entered in the box....
i don't know if i configured something wrong in my php setup prosses
cuz it won't return the dataWelcome to the forums.This should really be in the PHP subforum.It looks to me like register globals is disabled on your server(this is a good thing),so in the page that displays what you submitted with the form..change:
echo $data;
to
echo $_POST["data"];that worked thanks
and how do i enable the register globals
any why is that a good thing to have them disabled?In php.ini...there is an option...register_globals...set it to on to enable them,or in httpd.conf you can put php_flag register_globals on .Having them disables increases security in your scripts...for example....with your previous code:
echo $data;
and register globals on...that variable could come from ANY request method/variable out of GET,POST,COOKIE,SERVER and ENVIRONMENT.Obviously you know the data should come from a POST method form...however,using just $data means I could:
Use the query string(ie: page.php?data=whateverIwant),which is the GET method
Use your form,which is the POST method
Have a cookie named data from your site with a value in it
If none of those are set,you may get one of the predefined SERVER or ENVIRONMENT variables
this is a big security hole and really doesn't make a few characters difference typing worth it.You can use:
$data = $_POST["data"];
if you need to use it in multiple places you can from then on just echo $data;