Ok I went through your code and found a few mistakes.
Here is the corrected version:
CREATE TABLE:
Code: Select all
<?php
$connection = mysql_connect ("localhost", "/", "/");
if ($connection == false){
echo mysql_errno().": ".mysql_error()."<BR>";
exit;
}
$query = "create table meszitup" .
"(
id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
yrname VARCHAR(50) NOT NULL,
email VARCHAR(50) NOT NULL,
phone VARCHAR(50) NOT NULL,
address VARCHAR(200) NOT NULL,
thetitle VARCHAR(250) NOT NULL,
description MEDIUMTEXT NOT NULL,
qty INT NOT NULL ,
price INT NOT NULL)";
$result = mysql_db_query ("/", $query);
if ($result)
echo "Table 'meszitup' was successfully created!";
else
echo mysql_errno().": ".mysql_error()."<BR>";
mysql_close ();
?>
SUBMIT-INSERT.PHP
Code: Select all
<html><head><title>uac submit</title></head>
<body>
<?
$yrname=$_POST['yrname'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$address=$_POST['address'];
$thetitle=$_POST['title'];
$description=$_POST['description'];
$qty=$_POST['qty'];
$price=$_POST['price'];
$db="/";
$link = mysql_connect("localhost","/","/");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link) or die("Select Error: ".mysql_error());
$result=mysql_query("INSERT INTO meszitup1 (yrname, email, phone, address, thetitle, description, qty, price) VALUES ('$yrname', '$email', '$phone', '$address', '$thetitle', '$description', '$qty', '$price')")or die("Insert Error: ".mysql_error());
mysql_close($link);
print "Record added\n";
?>
<form method="POST" action="submit.php">
<input type="submit" value="submit">
</form>
</body>
</html>
SUBMIT.PHP is ok
Corrections:
- took out PRIMARY KEY (id) : it was already included above
- erased $id=$_POST['id']; : as the id is automatic
- erased id from the query too
- renamed $thetitle=$_POST['title']; : as the variable has that name in your form
- renamed table to meszitup
That's it !