Welcome to WebmasterWorld Guest from 54.158.143.40

Forum Moderators: phranque

Message Too Old, No Replies

Very strange Browser output

   
2:00 pm on Jun 5, 2013 (gmt 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 Jun 5, 2013 (gmt 0)

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



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 Jun 5, 2013 (gmt 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 Jun 5, 2013 (gmt 0)



Hi Fotiman,

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

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

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



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 Jun 5, 2013 (gmt 0)

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



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.)