Code: Select all
<?php
$id=$_GET['id'];
$username="XXXX";
$password="YYYYY";
$database="forms";
$first=$_POST['first'];
$last=$_POST['last'];
$phone=$_POST['phone'];
$mobile=$_POST['mobile'];
$fax=$_POST['fax'];
$email=$_POST['email'];
$web=$_POST['web'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
//$query = "INSERT INTO contacts VALUES ('','$first','$last','$phone','$mobile','$fax','$email','$web')";
$query=("INSERT INTO contacts (first, last, phone, mobile, fax, email, web) VALUES ('" . $first . "','" . $last . "','" . $phone . "','" . $mobile . "','" . $fax . "','" . $email ."','" . $web . "')" );
mysql_query($query);
mysql_close();
?>FORM:
Code: Select all
<body>
<form action="insert.php" method="post">
First Name: <input name="first" type="text" size="20"/>
<br>
Last Name: <input name="last" type="text" size="20">
<br>
Phone: <input name="phone" type="text" size="20">
<br>
Mobile: <input name="mobile" type="text" size="20">
<br>
Fax: <input name="fax" type="text" size="20">
<br>
E-mail: <input name="email" type="text" size="20">
<br>
Web: <input name="web" type="text" size="20">
<br>
<input type="Submit">
</form>