I am using a form to insert data into a table I have created. I get no errors but for some reason, it states it worked, although it does not insert any data,
Here is what I'm using:
This is the form page:
<form name="myForm" action="submitform.php"
onsubmit="return validateForm()" method="post">
Name:
<br />
<input type="text" name="fname" style="
Email:
<br />
<input type="email" name="email" >
Subject:
<br />
<input type="text" name="subject">
Message:
<br />
<textarea name="message" >
</textarea>
<input type="submit" value="Send Message" name="add" >
</form>
phpsidecode
<?php
if(isset($_POST['add']))
{
$submit=$_POST['add'];
$Name=$_POST['fname'];
$Email=$_POST['email'];
$Subject=$_POST['subject'];
$Message=$_POST['message'];
$dbhost='localhost';
$dbnmae='someuser';
$dbpass='somepassword';
$conn = mysql_connect($dbhost,$dbnmae,$dbpass);
if (!$conn) {
die('Could not connect: '.mysql_error());
}
$sql="INSERT INTO mydb(name, email, subject, message)VALUES('$Name', '$Email', '$Subject', '$Message')";
mysql_select_db('project1');
$retrieval=mysql_query($conn,$sql);
if(!$retrieval)
{ die('Could not connect: '.mysql_error());
}
echo"Entered data successfully\n";
mysql_close($conn);
}else
{ echo"something went to wrong";
}
?>