2

enter image description here I'm just following w3schools like a normal person

For me getting php to work is harder than learning the language itself... If somebody could please provide an extensive guide on common problems such as this one that would be heavily resourceful

I'd also like to know the ins and outs of running php scripts within an html context, not having the php extension on the browser would be preferred in most cases

I can't get the following script to run upon submitting the form. It ends up opening up a window asking me which program should be used to run the php file.

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="welcome.php" method="get">
Name: <input type="text" name="name"> <br>
E-mail: <input type="text" name="email"> <br>
<input type="submit">
</body>
</form>

Opening the php file using firefox accomplishes the same thing.

If so, which program should I use? or do I need to update some configuration in order to get this simple script to work

<html>
<body>
Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>
</body>
</html> 
AkaLee
  • 69
  • 4
  • 5
    See: https://stackoverflow.com/questions/1678010/php-server-on-local-machine You can view HTML in any old browser locally, but you need the machine to understand the PHP – Stephen May 27 '18 at 06:27
  • Here I am thinking simply having php installed would resolve this issue – AkaLee May 27 '18 at 06:30
  • 1
    Browsers are designed to process HTML and turn all of the various tags into something to view on the screen, so HTML will display nativly. PHP does everything it needs to do and then dynamically produces HTML to output to a browser. What you need on your local machine is the same as is available on a hosting account, a web-server. The thread I posted above is good, but there are loads of local web-servers available. XAMPP as @Mark has suggested below and WAMP are the best of the bunch for Windows machines. – Stephen May 27 '18 at 07:03
  • SO is for asking specific questions, not for extensive guides on anything. – James Z May 27 '18 at 07:23

1 Answers1

1

One of the easiest ways to get PHP up and running for a newbie would be to use XAMPP. See this Wikihow article on how to get that done: https://www.wikihow.com/Set-up-a-Personal-Web-Server-with-XAMPP

Good luck!

Mark
  • 1,058
  • 10
  • 13
  • I have apache set up, in fact the php is under var/www I feel I'm missing out on something that's easily fixable but not easy to spot – AkaLee May 27 '18 at 07:15
  • I wouldn't call myself a newbie per se. I have coded my own web server before ( very simple, lot stuff going on and PHP is already the final form) I was under the assumption that you didn't have to initialize apache2 but you actually do and that's what solved the issue for me. The fact that I am actually running it under local host which makes sense because the server I coded was running under 127.0.0.1 as well. Then there is the recently discovered functionality of localhost in your browser to try and access wathever server you're running. Not sure what would happen if itused different pr – AkaLee May 27 '18 at 07:38