I have been trying to build a form for my new website. When the submit button is clicked, it will run a php file which will send the form input to a mysql database.
I have tested the php file and it communicates fine with the db, but I think I have issues within the form html because the info does not get inputted. I was hoping you guys could take a look at my code to see if you can identify any problems. Thanks. Here's the form html:
<form id="form" form method="post" action="insertbrewpub.php">
<div class="success">Contact form submitted!<br>
<strong>We will be in touch soon.</strong> </div>
<fieldset>
<label class="name">
<input type="text" value="Name:">
<span class="error error-empty">*This is not a valid name.</span><span class="empty error-empty">*This field is required.</span> </label>
<label class="address">
<input type="text" value="Address:">
<span class="error error-empty">*This is not a valid email address.</span><span class="empty error-empty">*This field is required.</span> </label>
<label class="city">
<input type="text" value="City:">
<span class="error error-empty">*This is not a valid city.</span><span class="empty error-empty">*This field is required.</span> </label>
<label class="phone">
<input type="tel" value="Phone:">
<span class="error error-empty">*This is not a valid phone number.</span><span class="empty error-empty">*This field is required.</span> </label>
<label class="website">
<input type="url" value="Website:">
</label>
<label class="description">
<textarea>Description:</textarea>
<span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span> </label>
<?php
$con = mysql_connect("localhost","dbname","dbpassword");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("dbname", $con);
$sql="INSERT INTO brewpubs (Name, Address, City, Phone, Website)
VALUES
('$_POST[Name]','$_POST[Address]','$_POST[City]','$_POST[Phone]','$_POST[Website]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Your brewpub has been added to the database";
I believe the issue is somewhere in the section where I am putting the input type, etc with the code for the formatted buttons code....if that makes sense?
Thanks for all of the help. I finally got the form working.........now I only have one other issue but it is php related so I posted it in the appropriate forum.