0

So, I'm trying to use a .php script to print data from a form, but everytime i try to call that script all i get is a page with the php code on it, and i can't figure out why. I don't have any errors in the code. Or at least it won't show me that i have any. Here is the code:

<DOCTYPE html>

<body>
<?php


if(isset($_POST['submit'])) 

{
    $firstName=$_POST['first'];
    
    $lastName=$_POST['last'];
    echo "Last Name: " .$lastName .$firstName . " <br />";
    $password=$_POST['pw'];
    echo "Password: " .$password . " <br />";
    $status =$_POST['status'];
    echo "Status: " .$status . "<br />";
    $waitList = $_POST['waitlist'];
    echo "Wait List: " .$waitList . "<br />";
}

?>

</body>

This is the main page code:

<!DOCTYPE html> 

<body>

<form name="register" action="process.php  " method="post" autocomplete="off" >
<p>First Name: <input type= "text" name="first" /></p>
<p>Last Name: <input type= "text" name="last" /></p>
<p>Pasword: <input type="password" name="pw"/></p>
<p>Status: 
    <input type="radio" name="status" value="enrolled" checked>Endrolled
    <input type="radio" name="status" value="notEnrolled">Not Enrolled </p>
<p><input type="checkbox" name="waitlist" value="true" checked="checked">Add me to the waiting list</p>
<p><input type="submit" name="submit" value="Sign in" /> </p>
</form> 
</body>

enter image description here

I really need some help with this, i am completly lost here..

3 Answers3

3

You have directly opened the file in the browser (you can see it from the photo), download a program like XAMPP to start a local server and view the content

Simone Rossaini
  • 8,115
  • 1
  • 13
  • 34
  • Although i needed some help with how it works, this was helpful, so thanks. – Alex Bidenia Dec 24 '20 at 11:11
  • Go [here](https://www.apachefriends.org/it/index.html) download XAMPP and install, next step go to localhost folder (ex: `C:\xampp\htdocs`) then put your file into this folder. Now open XAMPP control panel start apache server and mysql(if you need) then open browser and put into url bar `localhost/NameOfFile.php` and have you finish – Simone Rossaini Dec 24 '20 at 21:22
0

You can not access the file directly. PHP code needs to be compiled. If you are using Windows WAMP device, you will run the server and log in via http Unlike PHP, running HTML is directly on the browser so you see your HTML "code"

see: https://www.makeuseof.com/tag/how-to-set-up-your-own-wampserver/

Eden Moshe
  • 1,097
  • 1
  • 6
  • 16
0

you should install xammp serverenter image description here

Nathan
  • 1
  • 2