Sunday 25 August 2013

add two fields from HTML form to one Mysql filed

add two fields from HTML form to one Mysql filed

I am trying to add 2 html form field on one Mysql field have tried this
code but unable inset the value to the database.
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$city= mysql_real_escape_string($_POST['city']);
$name = mysql_real_escape_string($_POST['name']. "-" . $_POST['domain']);
$alias = mysql_real_escape_string($_POST['alias']);
$date = mysql_real_escape_string($_POST['Date']);
$user = mysql_real_escape_string($_POST['user']);
$id = mysql_real_escape_string($_POST['id']);
$all1 = implode(",",$city);
$all2 = implode(",",$name);
$all3 = implode(",",$alias);
$all4 = implode(",",$date);
$all5 = implode(",",$user);
$all6 = implode(",",$id);
$all1e = explode(",",$city);
$all2e = explode(",",$name);
$all3e = explode(",",$alias);
$all4e = explode(",",$date);
$all5e = explode(",",$user);
$all6e = explode(",",$id);
$insert = mysql_query ("INSERT INTO `Dname` (`city`, `name`, `alias`,
`user`, `Date`, `id`) VALUES
('$all1e','$all2e','$all3e','$all4e','$all5e'");
//insert null for id place holder
$insert .= "'')";
$res = mysql_query($insert) or die(mysql_error());
}

No comments:

Post a Comment