Welcome to WebmasterWorld Guest from 54.167.40.25

Forum Moderators: phranque

Message Too Old, No Replies

Very strange Browser output

     
2:00 pm on Jun 5, 2013 (gmt 0)

New User

joined:May 25, 2013
posts: 20
votes: 0


Hi,

Here are my codes:
test1.html

<!doctype html>

<html lang="en">

<head>
</head>

<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="fname">
Age: <input type="text" name="age">
<input type="submit">
</form>

</body>
</html>

welcome.php
Welcome <?php echo $_POST["fname"]; ?>!<br>
You are <?php echo $_POST["age"]; ?> years old

Output on browser
Welcome <?php echo $_POST["fname"]; ?>!<br>
You are <?php echo $_POST["age"]; ?> years old

Browser URI
file:///C:/xampp/htdocs/welcome.php


I am running XAMPP with Apache server. Seems like parameters from form not passed to welcome.php file.

Do you know what is the matter?
2:31 pm on June 5, 2013 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 17, 2005
posts: 4966
votes: 10


file:///

You're accessing the file directly instead of through your Apache server. You need to access via http:// and point it at your server, otherwise no server side processing can happen.
2:53 pm on June 5, 2013 (gmt 0)

New User

joined:May 25, 2013
posts: 20
votes: 0


Hi Fotiman,

If my XAMPP default directory is c:\xampp\htdocs. How do I convert this to http for welcome.php?

Can you just give me an example?

Godfrey
3:05 pm on June 5, 2013 (gmt 0)

New User

joined:May 25, 2013
posts: 20
votes: 0


Hi Fotiman,

Thank you very much for your reply. Much appreciated...

Godfrey
3:19 pm on June 5, 2013 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 17, 2005
posts: 4966
votes: 10


So, if it's running as a server, then you would probably do something like
http://localhost/test1.html (depends on how you've configured it and if you're in a subdirectory, etc.)
8:49 pm on June 5, 2013 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
posts:12714
votes: 244


If it behaves approximately the same as MAMP, you need to go into its preferences --or whatever your platform calls them-- and select a default directory.

You can never open the file directly from your desktop; it has to be done within the browser. Make a "WAMP site" or similar bookmark and you won't have to memorize the URL. (Mine's http:/ /localhost:8888/ That's the free version, where you can only use one domain at a time. I think the fancier version comes with a pseudo-DNS so you can do multiple domains.)