AbbasAkhtar
Programmer
Hello, I need some help with php, this is what I'm trying to do is pass on variables/parameters from one html page to another, it really is important, I'll explain my problem near the end, this is my system configuration.
Windows Millenium Edition
My online digitalamt.co.uk server is apache, so I have downloaded and set up apache on my laptop, which is version 2.0.4.5. (I've tried 1.3.5 too, but the same thing happens)
I have installed MySQL 3.21.# (but I am not concerned with this just now).
I also have installed PHP 4.
OK this is what I am trying to do, I have put all my files in the htdocs folder, I have 2 files, one called index.html and the other called information.php.
This is what happens, in the index.html, it contains 2 text boxes, and a submit button, what is supposed to happen is that the information.php file is supposed to receive the variables/parameters so it can display it on the other page. This is the code I am using for both files.
*********************index.html*****************************
<html>
<head>
<title>My Form</title>
</head>
<body>
<form action="information.php" method=post>
My name is:
<br> <input type="text" name="nam">
<p>
My age is:
<br> <input type="text" name="age">
<p>
<input type="submit" name="submit" value="Enter my Data!">
</form>
</body>
</html>
**************end of index.html***************************
************************information.php********************
<html>
<head>
<title>Information</title>
</head>
<body>
Hi <?php print $nam; ?>
<p>
You are <?php print $age; ?> years old.
<p>
Bye.
</body>
</html>
***************end of information.php**********************
The above two files which are in my htdocs, both load normally, but when I hit submit, this is what happens:
the page loads in ie, when I navigate to localhost or 127.0.0.1 the index.html loads perfectly, I input data,
I hit submit, on the next page (information.php) I receive this on the page:
**********************when information.php loads***********
Hi
Notice: Undefined variable: nam in C:\Program Files\Apache Group\Apache2\htdocs\information.php on line 6
You are
Notice: Undefined variable: age in C:\Program Files\Apache Group\Apache2\htdocs\information.php on line 8
years old.
Bye.
************************************************************
It works normally, if I use variables in a single html page, but if I try to pass them to other html files, it doesn't work. I have tried method=get and method=post none of them work. Is it something to do with my php.ini file in my windows directory. I am not really sure which ini setting I should edit, although I have had a look.
Any help would be appreciated, thanks. p.s. I don't have the apache monitor activated, I've tried it whilst activated and whilst shut down.
And I couldn't get this to work either:
******************index2.php******************
<html>
<head>
<title>Test PHP</title>
</head>
<body>
<?php
//just an experimental php script
print "<p>The value is:" + $username;
?>
<input type="text" name="$username" size="40" maxlength="40" value="hi">
<?php
//just an experimental php script
print "<p>The value is:" + $username;
?>
</body>
</html>
************************************************
also, I set up in apache the httpd.conf to run php files with php.exe in C:/php/ which is fine, although I did not try the cgi module, which is php4apache.dll which I can not find in the php folder, and I don't know where I can find it to install it, maybe I need this to make it work,
any help will be appreciated. thankyou. even if you could explain how you set up your apache and php. thanks.
Windows Millenium Edition
My online digitalamt.co.uk server is apache, so I have downloaded and set up apache on my laptop, which is version 2.0.4.5. (I've tried 1.3.5 too, but the same thing happens)
I have installed MySQL 3.21.# (but I am not concerned with this just now).
I also have installed PHP 4.
OK this is what I am trying to do, I have put all my files in the htdocs folder, I have 2 files, one called index.html and the other called information.php.
This is what happens, in the index.html, it contains 2 text boxes, and a submit button, what is supposed to happen is that the information.php file is supposed to receive the variables/parameters so it can display it on the other page. This is the code I am using for both files.
*********************index.html*****************************
<html>
<head>
<title>My Form</title>
</head>
<body>
<form action="information.php" method=post>
My name is:
<br> <input type="text" name="nam">
<p>
My age is:
<br> <input type="text" name="age">
<p>
<input type="submit" name="submit" value="Enter my Data!">
</form>
</body>
</html>
**************end of index.html***************************
************************information.php********************
<html>
<head>
<title>Information</title>
</head>
<body>
Hi <?php print $nam; ?>
<p>
You are <?php print $age; ?> years old.
<p>
Bye.
</body>
</html>
***************end of information.php**********************
The above two files which are in my htdocs, both load normally, but when I hit submit, this is what happens:
the page loads in ie, when I navigate to localhost or 127.0.0.1 the index.html loads perfectly, I input data,
I hit submit, on the next page (information.php) I receive this on the page:
**********************when information.php loads***********
Hi
Notice: Undefined variable: nam in C:\Program Files\Apache Group\Apache2\htdocs\information.php on line 6
You are
Notice: Undefined variable: age in C:\Program Files\Apache Group\Apache2\htdocs\information.php on line 8
years old.
Bye.
************************************************************
It works normally, if I use variables in a single html page, but if I try to pass them to other html files, it doesn't work. I have tried method=get and method=post none of them work. Is it something to do with my php.ini file in my windows directory. I am not really sure which ini setting I should edit, although I have had a look.
Any help would be appreciated, thanks. p.s. I don't have the apache monitor activated, I've tried it whilst activated and whilst shut down.
And I couldn't get this to work either:
******************index2.php******************
<html>
<head>
<title>Test PHP</title>
</head>
<body>
<?php
//just an experimental php script
print "<p>The value is:" + $username;
?>
<input type="text" name="$username" size="40" maxlength="40" value="hi">
<?php
//just an experimental php script
print "<p>The value is:" + $username;
?>
</body>
</html>
************************************************
also, I set up in apache the httpd.conf to run php files with php.exe in C:/php/ which is fine, although I did not try the cgi module, which is php4apache.dll which I can not find in the php folder, and I don't know where I can find it to install it, maybe I need this to make it work,
any help will be appreciated. thankyou. even if you could explain how you set up your apache and php. thanks.