0

Hello im creating a basic form which will be sent to php file , that will connect to database (the database is mySQL and its running under phpmyadmin on a hosting) now what i cant figure out is that , why always when i submit the form , it lets me download the php file it is sending the form to , it always pops out where to save check.php (its the file im sending the form to) the html and php file are locally in my computer not on the hosting

i have a basic html form with one field and submit button

<form action="submit.php" method="POST">
  Name :<br>
  <input type="text" name="name">
<br><br>
  <input type="submit" value="Submit">
</form>

now the php file (ignore the names of db or user , i was trying it with working ones , this is just an example)

<html>
<body>
<?php

$servername = "example";
$username = "example";
$password = "example";
$dbname = "example";


$conn = mysqli_connect($servername, $username, $password, $dbname);

if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

mysqli_close($conn);
?> 

</body>
</html>

so thats all , i just want to get printed out the message that it has successfuly connected , whats wrong? it just pops out , downloading submit.php

Jessica99
  • 57
  • 4
  • Does your hosting allow remote connections from your computer? – A.L Feb 28 '16 at 14:13
  • i have no idea , i thought i can connect to a phpmyadmin db from wherever i want to – Jessica99 Feb 28 '16 at 14:14
  • PhpMyAdmin is not a database, this is a web application to manage MySQL databases. If the server send you the PHP file, it's probably that the Web server is not configured to interpret PHP. – A.L Feb 28 '16 at 14:16
  • alright so cant i connect to mysql db running under phpmyadmin from my local pc? – Jessica99 Feb 28 '16 at 14:17
  • Yes, you should first configure your local server in order to test your PHP code with a local MySQL database. You can use WAMP for Windows, MAMP for Mac OS, etc. – A.L Feb 28 '16 at 14:18

0 Answers0