0

Browser output is my the code that makes up the php file I am attempting to execute. I want the php to take form input and just display the echo.

I have run the php by itself and it runs fine. For example, I have given variable values and echoed them and it prints correctly.

How do I make the php file take what is entered into the html file and the execute?

HTML form:

<form action="my_page.php" type="post">
Email:<input name="email" type="text"><br>
Password:<input name="password" type="password">
<input type="submit" value="Submit">
</form>

php:

<?php
//Variables
$email = $_POST['email'];
$password = $_POST['password'];

echo "Your account email is: " + $email + " and password is: " + 
$password"; 
?>

The browser display is:

<?php
//Variables
$email = $_POST['email'];
$password = $_POST['password'];

echo "Your account email is: " + $email + " and password is: " + 
$password"; 
?>

which is the same as the php code. I want it to display "Your account email is: (whatever email is entered) and password is (whatever password is entered)"

geoyoung
  • 1
  • 1
  • How are you testing this then? Sounds like you don’t have a web server running to begin with, or at least one that doesn’t have PHP integration configured. – 04FS Jul 03 '19 at 07:17
  • @04FS I have attempted to configure my web server using steps laid out in an answer to a similar question. Any obvious configuration steps for a newbie to web servers? – geoyoung Jul 03 '19 at 07:34
  • Least effort required and most beginner-friendly option would probably be if you went with something like XAMPP, https://en.wikipedia.org/wiki/XAMPP – 04FS Jul 03 '19 at 07:38
  • @04FS That is what I have been using. I just cannot get php to execute when running from the HTML form. If am too far ahead of self, what should I master first? – geoyoung Jul 03 '19 at 07:45
  • Do you see the proper XAMPP dashboard, when you call `http://localhost/` in your browser? Did you place your files below the `htdocs` directory? How are you accessing the whole thing in your browser, via which exact address? – 04FS Jul 03 '19 at 07:47
  • @04FS yes I do. The files are under C:/xampp/htdocs. localhost:8080/my_page.php (8080 was changed for testing and hasn't affected anything) – geoyoung Jul 03 '19 at 07:52
  • Well the code as shown contains syntax errors, but that should not make it _display_ the code, but cause either a blank page or an error message. – 04FS Jul 03 '19 at 07:54

0 Answers0