Hi there I am trying to add some data from a form into a MySQL database and it doesn't seem to been working. Any help would be appreciated.
PHP
<?php
if(isset($_POST['add']))
{
$dbhost = 'localhost';
$dbuser = '';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$businessname = $_POST['businessname'];
$businessgenre = $_POST['businessgenre'];
$shortbusinessdescription = $_POST['shortbusinessdescription'];
$longbusinessdescription = $_POST['longbusinessdescription'];
$businesswebsiteaddress = $_POST['businesswebsiteaddress'];
$businessphonenumber = $_POST['businessphonenumber'];
$businesscontactemail = $_POST['businesscontactemail'];
$businesstags = $_POST['businesstags'];
$sql = "INSERT INTO database ".
"(businessname, businessgenre, shortbusinessdescription, longbusinessdescription, businesswebsiteaddress, businessphonenumber, businesscontactemail, businesstags) ".
"VALUES ".
"('$businessname','$businessgenre','$shortbusinessdescription', '$longbusinessdescription', '$businesswebsiteaddress', '$businessphonenumber', '$businesscontactemail', '$businesstags')";
mysql_select_db('armannwe_bakery');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully\n";
mysql_close($conn);
}
else
{
?>
<?php
}
?>
HTML
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><form name="form1" method="post" action="insert_ac.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td colspan="3"><strong>Add your business for a free listing today </strong></td>
</tr>
<tr>
<td width="71">Business Name</td>
<td width="6">:</td>
<td width="301"><input name="businessname" type="text" id="businessname"></td>
</tr>
<tr>
<td>Business Genre</td>
<td>:</td>
<td><input name="businessgenre" type="text" id="businessgenre"></td>
</tr>
<tr>
<td>Short Business Description</td>
<td>:</td>
<td><input name="shortbusinessdescription" type="text-area" id="shortbusinessdescription"></td>
</tr>
<tr>
<td>Long Business Description</td>
<td>:</td>
<td><input name="longbusinessdescription" type="text-area" id="longbusinessdescription"></td>
</tr>
<tr>
<td>businesswebsiteaddress</td>
<td>:</td>
<td><input name="businesswebsiteaddress" type="text" id="businesswebsiteaddress"></td>
</tr>
<tr>
<td>businessphonenumber</td>
<td>:</td>
<td><input name="businessphonenumber" type="text" id="businessphonenumber"></td>
</tr>
<tr>
<td>businesscontactemail</td>
<td>:</td>
<td><input name="businesscontactemail" type="text" id="businesscontactemail"></td>
</tr>
<tr>
<td>businesstags</td>
<td>:</td>
<td><input name="businesstags" type="text" id="businesstags"></td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>