Jump to content

PHP being read from HTML Problem


ignaton

Recommended Posts

I'm just a begun coding but seem to have a problem with php code being read from html. Basically my php is not being read correctly as far as I can tell.  I have pasted my code(gotten from a tutorial) below and below that is the results in my browser window. 

 

Source ---

 

<html>

<head>

<title>My First PHP Page</title>

</head>

<body>

 

<h1>Hello </h1>

 

 

<?php

echo "Hello World!";

?>

 

 

</body>

</html>

 

 

 

Results ------------

 

Hello

 

 

If I put the php in a file it also doesn't work properly as shown below.

 

HTML Code ----------

 

 

<form action="welcome.php" method="post">

Enter your name: <input type="text" name="name" />

Enter your age: <input type="text" name="age" />

<input type="submit" />

</form>

 

Welcome.php  code --------

 

<html>

<body>

 

Welcome <?php echo $_POST["name"]; ?>.<br />

You are <?php echo $_POST["age"]; ?> years old.

 

</body>

</html>

 

 

Results ---------

 

Welcome .

You are years old.

 

The problem appears both with WAMP and XAMPP installs (I couldn't get apache/php/mysql to work when installed separately) so I not sure whether I have an install issue(I have attempted multiply reinstall's) or it a coding problem, though I consulted numerous tutorials and nothing has worked for me. I sorry if this is not in the correct section to be posting this question. Thanks of course for any replies.

Link to comment
https://forums.phpfreaks.com/topic/141892-php-being-read-from-html-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.