apache php question...help needed plz

hie everyone,

at school we are learning php. and this is the code that i had to execute in class:


<HTML>
<HEAD><TITLE>Een voorbeeld</TITLE></HEAD>
<BODY>
	<FORM method="post" action="<?php echo $_SERVER'SCRIPT_NAME']; ?>">
	Voornaam:<input type="text" name="voornaam" value="<?php echo $_POST'voornaam']; ?>" /></br>
	Achternaam: <input type="text" name="achternaam" value="<?php echo $_POST'achternaam']; ?>" /></br>
	<input type="submit" value="Sla op" />
	</FORM>
	

	<?php 
		if ($_SERVER'REQUEST_METHOD'] == 'POST')
		{
			if ($_POST'voornaam'] && $_POST'achternaam'])
			{
				echo 'Sla op in database';
			}
			else 
			{
				echo 'u moet';
			}
		}
	?>	
	
</BODY>
</HTML>

it went wrong, and since i use linux and rest of the school (guess what) windows teacher told that he could’t help me.
I use Quanta 3.5 for this calss.
After i typed the code i tryed to view it. I could see entry boxes and the button “Sla op”, but entry boxes are feeled by:


<?php echo $_POST'voornaam']; ?>

it seems like php script is not red.
apache is running.
please tell me what i got to do to make php work.
thnx

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Do you have PHP for Apache installed on the box as well? Post the
output to the following command:

rpm -qa | grep -i php

Also, while we can try to be fast with replying, search back through
this forum for related issues. This has come up quite a few times and
some of the experts have responded with every step known to man that
will probably get you where you want to be. Basically be sure you have
the modules installed (see above command to verify) have Apache
configured, restart Apache, run.

And your teacher is a pansy. :wink:

Good luck.

nikotron wrote:
> hie everyone,
>
> at school we are learning php. and this is the code that i had to
> execute in class:
>
> Code:
> --------------------
>
> <HTML>
> <HEAD><TITLE>Een voorbeeld</TITLE></HEAD>
> <BODY>
> <FORM method=“post” action="<?php echo $_SERVER’SCRIPT_NAME’]; ?>">
> Voornaam:<input type=“text” name=“voornaam” value="<?php echo $_POST’voornaam’]; ?>" /></br>
> Achternaam: <input type=“text” name=“achternaam” value="<?php echo $_POST’achternaam’]; ?>" /></br>
> <input type=“submit” value=“Sla op” />
> </FORM>
>
>
> <?php
> if ($_SERVER’REQUEST_METHOD’] == ‘POST’)
> {
> if ($_POST’voornaam’] && $_POST’achternaam’])
> {
> echo ‘Sla op in database’;
> }
> else
> {
> echo ‘u moet’;
> }
> }
> ?>
>
> </BODY>
> </HTML>
>
> --------------------
>
>
> it went wrong, and since i use linux and rest of the school (guess
> what) windows teacher told that he could’t help me.
> I use Quanta 3.5 for this calss.
> After i typed the code i tryed to view it. I could see entry boxes and
> the button -“Sla op”-, but entry boxes are feeled by:
>
> Code:
> --------------------
>
> <?php echo $_POST’voornaam’]; ?>
>
> --------------------
>
> it seems like php script is not red.
> apache is running.
> please tell me what i got to do to make php work.
> thnx
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFI7jLX3s42bA80+9kRAonhAJ4qmdqcXcrVR2SP+psF75wUQ1mjnwCfSq1Y
sIWIzIZZs0d/xWZ+bb271/k=
=VS4Z
-----END PGP SIGNATURE-----

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Also if you have PHP command-line version (CLI) installed you can force
the file through that manually to see that the output is what you expect
even without a web server. This may not work for your teacher depending
on if (s)he really wants you to have your own working web server for
demonstrations (which wouldn’t make sense to me for grading, but
whatever) but it will let you do testing without a web browser or server.

php5 /path/to/PHP/file.php

Good luck.

ab@novell.com wrote:
> Do you have PHP for Apache installed on the box as well? Post the
> output to the following command:
>
> rpm -qa | grep -i php
>
> Also, while we can try to be fast with replying, search back through
> this forum for related issues. This has come up quite a few times and
> some of the experts have responded with every step known to man that
> will probably get you where you want to be. Basically be sure you have
> the modules installed (see above command to verify) have Apache
> configured, restart Apache, run.
>
> And your teacher is a pansy. :wink:
>
> Good luck.
>
>
>
>
>
> nikotron wrote:
>> hie everyone,
>
>> at school we are learning php. and this is the code that i had to
>> execute in class:
>
>> Code:
>> --------------------
>
>> <HTML>
>> <HEAD><TITLE>Een voorbeeld</TITLE></HEAD>
>> <BODY>
>> <FORM method=“post” action="<?php echo $_SERVER’SCRIPT_NAME’]; ?>">
>> Voornaam:<input type=“text” name=“voornaam” value="<?php echo $_POST’voornaam’]; ?>" /></br>
>> Achternaam: <input type=“text” name=“achternaam” value="<?php echo $_POST’achternaam’]; ?>" /></br>
>> <input type=“submit” value=“Sla op” />
>> </FORM>
>
>
>> <?php
>> if ($_SERVER’REQUEST_METHOD’] == ‘POST’)
>> {
>> if ($_POST’voornaam’] && $_POST’achternaam’])
>> {
>> echo ‘Sla op in database’;
>> }
>> else
>> {
>> echo ‘u moet’;
>> }
>> }
>> ?>
>
>> </BODY>
>> </HTML>
>
>> --------------------
>
>
>> it went wrong, and since i use linux and rest of the school (guess
>> what) windows teacher told that he could’t help me.
>> I use Quanta 3.5 for this calss.
>> After i typed the code i tryed to view it. I could see entry boxes and
>> the button -“Sla op”-, but entry boxes are feeled by:
>
>> Code:
>> --------------------
>
>> <?php echo $_POST’voornaam’]; ?>
>
>> --------------------
>
>> it seems like php script is not red.
>> apache is running.
>> please tell me what i got to do to make php work.
>> thnx
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFI7jND3s42bA80+9kRAhikAJ4vYdAZVV6fmzf+IpoxLa7Mjdsd3gCfazkr
4vN4FIFuO8bqMNwriIb6Vtw=
=+g0L
-----END PGP SIGNATURE-----

Also, in my opinion, you should replace:

if ($_SERVER’REQUEST_METHOD’] == ‘POST’)

with:

if ($_SERVER’REQUEST_METHOD’] === ‘POST’)

  • note the 3 equals signs. Currently it will probably trigger all the
    time as you are just checking the variable’s type, not content :wink:

nikotron wrote:
> hie everyone,
>
> at school we are learning php. and this is the code that i had to
> execute in class:
>
> Code:
> --------------------
>
> <HTML>
> <HEAD><TITLE>Een voorbeeld</TITLE></HEAD>
> <BODY>
> <FORM method=“post” action="<?php echo $_SERVER’SCRIPT_NAME’]; ?>">
> Voornaam:<input type=“text” name=“voornaam” value="<?php echo $_POST’voornaam’]; ?>" /></br>
> Achternaam: <input type=“text” name=“achternaam” value="<?php echo $_POST’achternaam’]; ?>" /></br>
> <input type=“submit” value=“Sla op” />
> </FORM>
>
>
> <?php
> if ($_SERVER’REQUEST_METHOD’] == ‘POST’)
> {
> if ($_POST’voornaam’] && $_POST’achternaam’])
> {
> echo ‘Sla op in database’;
> }
> else
> {
> echo ‘u moet’;
> }
> }
> ?>
>
> </BODY>
> </HTML>
>
> --------------------
>
>
> it went wrong, and since i use linux and rest of the school (guess
> what) windows teacher told that he could’t help me.
> I use Quanta 3.5 for this calss.
> After i typed the code i tryed to view it. I could see entry boxes and
> the button -“Sla op”-, but entry boxes are feeled by:
>
> Code:
> --------------------
>
> <?php echo $_POST’voornaam’]; ?>
>
> --------------------
>
> it seems like php script is not red.
> apache is running.
> please tell me what i got to do to make php work.
> thnx
>
>

thnx for ur reply.
this is what i got:



nikoshiba:/home/nikom # rpm -qa | grep -i php
php5-json-5.2.6-0.4
php5-dom-5.2.6-0.4
php5-xmlreader-5.2.6-0.4
php5-tokenizer-5.2.6-0.4
php5-pdo-5.2.6-0.4
php5-mysql-5.2.6-0.4
php5-5.2.6-0.4
php5-iconv-5.2.6-0.4
apache2-mod_php5-5.2.6-0.4
php5-sqlite-5.2.6-0.4
php5-hash-5.2.6-0.4
php5-xmlwriter-5.2.6-0.4
php5-ctype-5.2.6-0.4

and

nikoshiba:/home/nikom # a2enmod php5
"php5" already present

this simple php file:


<?php
phpinfo();
?>

when opened in konqueror (or any other browser) doesn’t give me anything. But if i place this file into /srv/www/htdocs and then type in address bar localhost/phpinfo.php the i get very nice php configuration site.
I thought that if i would do the same with file from my class it would work…but it doesn’t.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Okay, looks like you are well on your way. Is your file name for your
test file ending in .php? If you end in .htm or .html then you are
getting the right thing, so be sure your file is ending in .php .

Good luck.

nikotron wrote:
> thnx for ur reply.
> this is what i got:
>
>
> Code:
> --------------------
>
>
> nikoshiba:/home/nikom # rpm -qa | grep -i php
> php5-json-5.2.6-0.4
> php5-dom-5.2.6-0.4
> php5-xmlreader-5.2.6-0.4
> php5-tokenizer-5.2.6-0.4
> php5-pdo-5.2.6-0.4
> php5-mysql-5.2.6-0.4
> php5-5.2.6-0.4
> php5-iconv-5.2.6-0.4
> apache2-mod_php5-5.2.6-0.4
> php5-sqlite-5.2.6-0.4
> php5-hash-5.2.6-0.4
> php5-xmlwriter-5.2.6-0.4
> php5-ctype-5.2.6-0.4
>
> --------------------
>
> and
>
> Code:
> --------------------
> nikoshiba:/home/nikom # a2enmod php5
> “php5” already present
>
> --------------------
>
>
> this simple php file:
>
> Code:
> --------------------
>
> <?php
> phpinfo();
> ?>
>
> --------------------
>
> when opened in konqueror (or any other browser) doesn’t give me
> anything. But if i place this file into /srv/www/htdocs and then type in
> address bar localhost/phpinfo.php the i get very nice php configuration
> site.
> I thought that if i would do the same with file from my class it would
> work…but it doesn’t.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFI7jzD3s42bA80+9kRAllCAJ0ck/rj+rVoDtsQD/5pBTKGrii5ugCdHMFC
DJVhTbjdtHSuQ8T8C6AKPIE=
=85y2
-----END PGP SIGNATURE-----

Saw this a bit late and they are all trying to help you, so I will not interfere. But one thing I must say, triggered by your:

teacher told that he could’t help me. I use Quanta 3.5 for this calss.

De leraar is een sukkel. Volkomen gespeend van gezonde nieuwsgierigheid in zijn vak. Tenzij dat vak MS Windows is en niet IT.

Sorry guys. But I had some comment on that teacher. And that teacher does not seem to be too bright, so I used his mother language.