Hey people

I'm in some dire need of assistance.
I am writing this small website which uses a database to store some info. Always when I call up add.php from the html file it shows every thing I've typed in the php file. I know its something small but can't seem to find the problem. Im using a MySQL database, a .php file and a .html file. Here's my code if someone can please help it would be appreciated.

---------------PHP FILE------------


if (mysqli_connect_errno())
  echo "Failed to connect to MySQL: " . mysqli_connect_error();

$sql="INSERT INTO Notes (ID, Subject, Name, Surname, ContactInfo, Email, Description, Format)
('$_POST[ID]','$_POST[Subject]','$_POST[Name]','$_POST[Surname]','$_POST[ContactInfo]','$_POST[Email]','$_POST[Description]','$_POST[Format]' )";

if (!mysqli_query($con,$sql))
  die('Error: ' . mysqli_error($con));
echo "1 record added";


-------------HTML File----------------

<form action="add.php" method="post"/>
<p>ID<input type="text" name="ID"/></p>
<p>Subject<input type="text" name="Subject"/></p>
<p>Name<input type="text" name="Name"/></p>
<p>Surname<input type="text" name="Surname"/></p>
<p>Contact Info<input type="text" name="ContactInfo"/></p>
<p>Email<input type="text" name="Email"/></p>
<p>Description of Notes<input type="text" name="Description"/></p>
<p>Printed or Written<input type="text" name="Format"/></p>
<p><input type="submit" /></p>

Recommended Answers

All 5 Replies


Are you running the script on the server or locally (on your desktop)? If so, you will need a developer server like XAMPP , easyPHP, or WAMP the choice is yours..

PHP cannot be parse by the browser alone.

If you are running it in NGINX http server, then the most common problem is in sites-available/default file.. Again, it all depends on how you set it up.

Please give us more info..

Hi thanks for your post.

Im running the script locally only for testing etc. After that I want to actually put it online. Should I download one of those developer servers stated above? And if I do will I need to make any changes to the script when I put It online

Appreciate your help


You can use xampp, wamp,nginx portable ( this require a lot of work, but lighter). I would recommend for you to use xampp, because just in case you will need more help in setting it up, there are many people that can help you out.

No, you do not need to make any changes when you put it online or the production server. In fact, you can directly import your local mysql database tables to your online database.

The public_html in xampp is called htdocs.

thanx alot

ill try it when Im finished with my exams and ill let you know if i'm stuck. thanx for your contribution

Member Avatar for diafol

If you don't have a WAMP/LAMP system installed, then your php files will spit out raw code as you don't have a server to process the php. Hosts, if they support PHP, will show the processed output from the code (usually html).

As mentioend by Veedeoo XAMPP is probably your best bet. The others are decent enough though - but check which version of php is being used and ensure that it's VC9 - not VC6. VC6 acts strangely on Windows, e.g. certain DateTime anomolies.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.