Jump to content

Insert into table


ronaldb103

Recommended Posts

I'm sure this has been asked many times but I can't seem to find a solution when I search the forums.  I can get my insert.php to connect to the database but it won't insert into the table.  Am I missing something?

 

<form action="insert.php" method="post">

First Name: <input type="text" name="first"><br>

Last Name: <input type="text" name="last"><br>

Phone: <input type="text" name="phone"><br>

Mobile: <input type="text" name="mobile"><br>

Fax: <input type="text" name="fax"><br>

E-mail: <input type="text" name="email"><br>

Web: <input type="text" name="web"><br>

<input type="Submit">

</form>

 

 

<?

$username="antondad";

$password="Ruthholmes1";

$database="antondad";

 

 

$first=$_POST['first'];

$last=$_POST['last'];

$phone=$_POST['phone'];

$mobile=$_POST['mobile'];

$fax=$_POST['fax'];

$email=$_POST['email'];

$web=$_POST['web'];

 

mysql_connect("antondad.db.4161444.hostedresource.com",$username,$password);

@mysql_select_db($database) or die( "Unable to select database");

echo 'Connected successfully';

mysql_query($query);

$query = "INSERT INTO contacts ('','$first','$last','$phone','$mobile','$fax','$email','$web')";

mysql_query($query) or die ( 'Unable to update databae');

echo "Database updated with " .$first. "" .$last. "" ;

 

mysql_close();

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/192206-insert-into-table/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.