0

i am trying to execute my php code, instead it just blows it back at my screen. page should be black to execute the code at the background.

I've let other poeple use this same code worked for them.

this is my code,

and this is the result of my code

Qirel
  • 25,449
  • 7
  • 45
  • 62
smeg
  • 19
  • 1
  • 3
  • 3
    You're executing you php file from local file, try to execute it on your local server e.g `localhost/phpmailer_test/index.php` not `file:///C:/xampp/htdocs/phpmailer_test/index.php` – A l w a y s S u n n y Jun 26 '19 at 16:25
  • 2
    @NathanClement That's not required. As long as the starting tag is there, it's fine. – aynber Jun 26 '19 at 16:33

2 Answers2

4

After setting xampp on your local pc, you've created a local server with apache, mysql, php stack. So when you write any php code, you need to execute/interpret it through your local server.

For example you need to use localhost/phpmailer_test/index.php not file:///C:/xampp/htdocs/phpmailer_test/index.php. If it was a .html file then you can use the file path to execute it but for server side language like php, python and so called server side languages you've to execute your code base through a server.

A l w a y s S u n n y
  • 36,497
  • 8
  • 60
  • 103
2

Seems like you are accessing your file through the file system, which means you are using your browser as something like a text editor. In order to have the php file executed on opening there are several things that you must do:

  1. Set up a server on your computer that can execute PHP. (MAMP or XAMPP are easy to install)
  2. Change the permissions of your server so that you can access it through localhost or 127.0.0.1.
  3. Set up the file system of your server so that you can find your PHP file.

In your case you are using XAMPP, so the htdocs folder should be the 'root' of your local server, then you will be able to access any folder within there by entering the path after htdocs. In your case it should be localhost/phpmailer test/index.php.

shn
  • 865
  • 5
  • 14