MAMP running, PHP not


Calling a php file from a simple HTML form - e.g., - get php source code in browser as result (see below).

Figured issue is that PHP is not running on localhost (using older version of MAMP). Checked, double-checked, and upgraded to latest MAMP PRO version (2.1.4).

Still have the same problem - PHP & Apache configs look correct.

Thoughts? (guessing that first suggestion will be to ditch MAMP.)


//Open a database connection
$con = mysqli_connect('localhost', 'root', 'root') or die( mysql_error() ); mysql_select_db($database) or die( mysql_error() );
//Declare variables for form data
$toDoItem = mysql_real_escape_string ($_POST["toDoItem"]);
$toDoDue = mysql_real_escape_string ($_POST["toDoDue"]);
$toDoOwner = mysql_real_escape_string ($_POST["toDoOwner"]);
$sql = "INSERT INTO toDo 
    (toDoItem, toDoDue, toDoOwner)
    VALUES  ($toDoItem, $toDoDue, $toDoOwner)";
$result = mysql_query($sql) or die( mysql_error() );
    echo ("<br>Data input successful.");
} else {
    echo ("<br>Data input failed.");
//close the connection



Do you get the MAMP screen when you go to localhost? I think that if you get the screen but click on PhpInfo it will also print out regular php statements.

It seems that it's because of a faulty install

People are also looking for solutions to the problem: Reading a form in wordpress with the plugin Exec-PHP


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.