Jump to content

Problem in inserting data into mysql db


fekaduw

Recommended Posts

hello everyone,

 

i was trying to insert a data into mysql db but my system inserts a given data twice. i tried to sort out the problem but i faild. Here is the code that inserts the data:

 

<?php
require("../includes/dbconnection.php");

$vid=$_POST["id"];
$vname =$_POST["firmname"];
$vtype=$_POST["type"];
$vcategory=$_POST["category"];
$vsubcity=$_POST["subcity"];
$vkebele=$_POST["kebele"];
$vhouseno=$_POST["houseno"];
$vtel=$_POST["telephone"];
$vpobox=$_POST["pobox"];
            $vfax=$_POST["fax"];
$vemail=$_POST["email"];
$vwebsite=$_POST["website"];
$vservices=$_POST["services"];

if(($vid=="")||($vid==0))
{
	$SQL="INSERT INTO tconsultant (name,type,category,subcity,kebele,houseno,tel,fax,email,website,services,pobox) values('".$vname."','".$vtype."','".$vcategory."','".$vsubcity."','".$vkebele."','".$vhouseno."','".$vtel."','".$vfax."','".$vemail."','".$vwebsite."','".$vservices."', '".$vpobox."')";
}
else
{
	$SQL="UPDATE tconsultant SET name='".$vname."',type='".$vtype."',category='".$vcategory."',subcity='".$vsubcity."',kebele='".$vkebele."',houseno='".$vhouseno."',tel='".$vtel."',pobox='".$vpobox."', fax='".$vfax."',email='".$vemail."',website='".$vwebsite."',services='".$vservices."' where id=".$vid;
}

mysql_query($SQL);
   header("Location: consultants.php");
exit();	
?>

 

any help is highly appreciated

Link to comment
https://forums.phpfreaks.com/topic/42532-problem-in-inserting-data-into-mysql-db/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.