I have a form that has an action that is a .php file and a method post.
but when i submit with a submit type button; all that happens is that the entire .php file is shown in the browser..
Seems like nothing inside it is being done it is just being showed?
any ideas to why this might be?
update:
Ok so I’ve checked and PHP is running on my db server. Now I’m really lost.
Then what can it possibly be?
enter code here<?php
$server = "*****";
$user = "******";
$password = "*******";
$db ="********";
$con = mysql_connect($server,$user,$password) or die(mysql_error());
echo("forbundet til server");
mysql_select_db($db) or die(mysql_error());
echo("forbundet til database");
$sql="INSERT INTO lejrskole1 (navn, postnummer)
VALUES
('$_POST[skole]','$_POST[postnummer]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?>
is the code.
The browser is interpreting the PHP as either text or HTML, but the PHP should never reach the browser.
Since PHP (in this context) is a server side programming language: you must access the PHP program through a web server that supports PHP and is configured to use it for that file.
If you have a webserver, then you’ll need to install a PHP module for it. If you don’t, then you’ll need to install one first. WAMP/MAMP/XAMPP will provide bundles for Windows or Mac. Almost any Linux or BSD distro will have it in their package management system already.