variables not working
| From: | eric lewis | Date: | Sat, 23 Jul 2005 15:27:03 +0000 |
| Subject: | variables not working | ||
| Groups: | php.install | ||
| Request: | Send a blank email to php-install+get-16516@lists.php.net to get a copy of this message | ||
Hi there
I have just installed PHP5 and Apache2 on a Windows 2K computer.
Everything seems to work OK, I see the default Apache screen, and I can
run phpinfo() and get the page full of data. I can even connect to my
mySQL database. But I can't transfer a simple variable from a form to
another php file. However it does work if I use $_POST['inputdata']. I
would much rather be able to use simple variables, and cannot work out
what I have done wrong, or need to change. The code for the pages is
extremely basic but I have reproduced it below.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<form action="formto.php" method="post" name="form1">
<input name="inputdata" type="text" id="inputdata"
size="20"
maxlength="20">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
<title>Untitled Document</title>
</head>
<body>
<?php // here I check that a simple statement will print
echo "Hello World"; ?>
<br />
<?php // here I create a variable, give it a value and print it
$testvariable = 'testdata';
echo $testvariable; ?>
<br />
the word that you entered was <?php // this is the input from my form
print $inputdata;
// but it will not appear here
?>
<br />
<br />
<?php
// however it WILL appear here
echo $_POST['inputdata']; ?>
<br />
</body>
</html>
I would very much appreciate any help that you can provide, I've been
going nowhere for hours with this! (it works fine on my hosting
companies server)
Thanks
Eric Lewis