"; PRINT "Insert New Product"; PRINT ""; $dbname = "example"; $pname = $_POST["pname"]; $pprice = $_POST["pprice"]; /* MySQL table created to store the data */ $tablename = "product"; /* make connection to database */ MYSQL_CONNECT("localhost","nis","thomas") OR DIE("Unable to connect to database server"); @mysql_select_db("$dbname") or die("Unable to select database"); $today = date("Y-m-d"); PRINT "Today is: $today.
"; PRINT "
"; PRINT "You issued the following INSERT query:
"; PRINT ""; PRINT "
"; /* Insert information into table */ $query = "INSERT INTO $tablename VALUES('$pname','$pprice', 'null')"; $result = MYSQL_QUERY($query); PRINT "Database server response:
"; if($result != 0){ $affected_rows = mysql_affected_rows(); PRINT "Query OK. Rows affected $affected_rows"; }else{ PRINT "Query FAILED. Probably you don't have the proper access rights!"; } PRINT "
"; PRINT "Back"; PRINT ""; PRINT ""; /* Close the database connection */ MYSQL_CLOSE(); ?>