I hv a form in my php file to accept some data from the user.
Then as shown below I capture the data using PHP.
the data is getting captured in the variables no prob with that.
but the data isn't getting saved to the database.
it should have something to do with my if cluases. pls let me knw the error.
thanks in advance...!!!! :)
[code=php]
<?php
if (isset($_POST['btnok']))
{
$image_id = $_GET['id'];
$title = $_POST['lsttitle'];
$fname = $_POST['txtfname'];
$lname = $_POST['txtlname'];
$email = $_POST['txtemail'];
$message = $_POST['txtmessage'];
echo "$title........ ";
echo"<br />";
$db_host = 'localhost';
$db_user = 'root';
$db_pwd = 'dba';
$database = 'gallery';
if (!mysql_connect ($db_host, $db_user, $db_pwd)) die("Can't connect to database");
if (!mysql_select_ db($database)) die("Can't select database");
if ($message==null or $fname==null)
{
echo "Please fill all required fields";
}
elseif ($fname==null or $lname==null)
{
echo "Please fill all required fields";
}
else
{
$result = mysql_query("in sert into inquiries(i_inq _title, i_inq_fname, i_inq_lname, i_inq_email, i_inq_message, i_inq_painting_ id) values ('".$title."' , '".$fname."' , '".$lname."' , '".$email."' , '".$message. "', '".$image_id."' )") or die("MYSQL Returned: ". mysql_error());
if($result==fal se)
{
echo "Couldnt complete the inquiry please try again!";
}
else
{
echo"did it";
//mysql_close();
}
}
}
?>
[/code]
Then as shown below I capture the data using PHP.
the data is getting captured in the variables no prob with that.
but the data isn't getting saved to the database.
it should have something to do with my if cluases. pls let me knw the error.
thanks in advance...!!!! :)
[code=php]
<?php
if (isset($_POST['btnok']))
{
$image_id = $_GET['id'];
$title = $_POST['lsttitle'];
$fname = $_POST['txtfname'];
$lname = $_POST['txtlname'];
$email = $_POST['txtemail'];
$message = $_POST['txtmessage'];
echo "$title........ ";
echo"<br />";
$db_host = 'localhost';
$db_user = 'root';
$db_pwd = 'dba';
$database = 'gallery';
if (!mysql_connect ($db_host, $db_user, $db_pwd)) die("Can't connect to database");
if (!mysql_select_ db($database)) die("Can't select database");
if ($message==null or $fname==null)
{
echo "Please fill all required fields";
}
elseif ($fname==null or $lname==null)
{
echo "Please fill all required fields";
}
else
{
$result = mysql_query("in sert into inquiries(i_inq _title, i_inq_fname, i_inq_lname, i_inq_email, i_inq_message, i_inq_painting_ id) values ('".$title."' , '".$fname."' , '".$lname."' , '".$email."' , '".$message. "', '".$image_id."' )") or die("MYSQL Returned: ". mysql_error());
if($result==fal se)
{
echo "Couldnt complete the inquiry please try again!";
}
else
{
echo"did it";
//mysql_close();
}
}
}
?>
[/code]
Comment