Insert Problem

gesf

New member
You may need to use the superglobals array. I suggest you to always use them!

For you to know what i´m talking about, please read this post!

So try this code:
Code:
<?php

/* This first line is just to prevent the script to run everytime this file is called */
if(isset($_POST['submit'])){

include("dbinfo.inc.php"); 
mysql_connect(localhost,$username,$password); 
@mysql_select_db($database) or die( "Unable to select database"); 

// So in this case, this is what you nedd: $_POST

$query = "INSERT INTO contacts VALUES ('','" . $_POST['first'] . "','" . $_POST['last'] . "','" . $_POST['phone'] . "','" . $_POS['mobile'] . "','" . $_POST['fax'] . "','" . $_POST['email'] . "','" . $_POST['web'] . "')"; 
mysql_query($query); 

mysql_close(); 

}

?>

Make sure you read the 2nd link i´ve posted!
 
Well with register_globals=On you don´t need the code i gave you.

For security reasons, you should always use register_globals=Off, and than use the superglobals array!

Well, your query seems to be right, however:

1st: I suggeat you to take the @ off of your mysql_select_db() function ´cause it will supress(not show) the function errors, so a mistake in your Database can could be the problem!

2nd: You better use error_reporting(E_ALL) in your code, so you´ll be notifyed about any error in your code!

3rd: You´re adding 'nothing' to your first table field, witch makes me think it´s an auto_increment field. Isn´t it !?
 
Back
Top