Im having a weird problem with getting my forms work within
php. I have a running MySQL server, php installed on a apache server
and I can make SQL queries through php, but Im unable to insert
any data into it through forms.

This is an example file that Im using
(its from





if ($submit) {

  // process form

  $db = mysql_connect("localhost", "root", "mypassword");


  $sql = "INSERT INTO employees (first,last,address,position) VALUES

  $result = mysql_query($sql);

  echo "Thank you! Information entered.\n";

} else{

  // display form


  <form method="post" action="<?php echo $PHP_SELF?>">

  First name:<input type="Text" name="first"><br>

  Last name:<input type="Text" name="last"><br>

  Address:<input type="Text" name="address"><br>

  Position:<input type="Text" name="position"><br>

  <input type="Submit" name="submit" value="Enter information">



} // end if



I have set the database in working order according to the manual, but after
I enter some writing into the
text fields and press submit: It refreshes the page and doesn't add any
information into the db.

I recon that the problem might be within the $php_self command, for I got
all the previous php/mySQL tutorials
working, but when this command appeared...problems started...or more
accurate word would be: nothing

I have phpMyAdmin 2.3.0 running on my apache server and it can send/receive
data from the db normally, so the problem shouldn't
be in the db server or in the php, so its in me or in the code :) I have
read through all the FAQ:s and manuals that I have found and I still
cant understand what is the problem in this one!


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to