473,549 Members | 3,109 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

insert the email id its not exit; if exit only update the row do not insert again

1 New Member
i have table in which first time insert the value in table
and second time when i was login with same email update row did no insert again.
my problem is that when i was my query my table is updated but insert once again the in next row;
i want that only update did not insert again
please solve my problem as soon as possible for you
here i am sending my php code below
Expand|Select|Wrap|Line Numbers
  1. if(!isset($_SESSION['user']))
  2. {
  3.     header("Location: ../index.php");
  4. }
  5.  
  6. $email=$_SESSION['user'];
  7. $res=mysql_query("SELECT * FROM user_businessleads WHERE user_email='$email'");
  8. $row=mysql_fetch_array($res);
  9.  
  10.   if(isset($_POST['submit']))
  11.   {
  12.        $looking_for = $_POST['looking_for'];
  13.         $services = $_POST['services'];
  14.         $mybudget = $_POST['mybudget'];
  15.         $around = $_POST['around'];
  16.         $s_reguirement = $_POST['s_reguirement'];
  17.         $chk="";
  18.     $email=$_SESSION['user'];  
  19.      foreach($services as $chk1)  
  20.    {  
  21.       $chk .= $chk1.",";
  22.  
  23. }
  24.  
  25.        $query=mysql_query("INSERT INTO user_businessleads(services,user_email,looking_for,mybudget,around,s_requirment)values('$chk','$email','$looking_for','$mybudget','$around','$s_reguirement')"); 
  26. }
  27.  if(isset($_POST['submit']))
  28.   {
  29.        $looking_for = $_POST['looking_for'];
  30.         $services = $_POST['services'];
  31.         $mybudget = $_POST['mybudget'];
  32.         $around = $_POST['around'];
  33.         $s_reguirement = $_POST['s_reguirement'];
  34.         $chk="";
  35.     $email=$_SESSION['user'];  
  36.      foreach($services as $chk1)  
  37.    {  
  38.       $chk .= $chk1.",";
  39.  
  40. }
  41.  $updated=mysql_query("UPDATE user_businessleads SET services='$chk',looking_for=' $looking_for',mybudget='$mybudget',around='$around',s_requirment='$s_reguirement' WHERE user_email='$email'")or die;
  42. }
  43. ?>
Mar 7 '16 #1
0 1194

Sign in to post your reply or Sign up for a free account.

Similar topics

1
6289
by: Derek Erb | last post by:
SQL Server 2000 : I have a series of tables which all have the same structure. When any of these tables are modified I need to syncrhonise all of those modifications with one other table wich is a sort of merge of the individual tables with one extra column. For most of these tables this is not a problem. The problem arrives when one of...
14
4273
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to salvage the records from the many table and without going into detail, one of the reasons I can't do the opposite as there are records in the ONE table...
1
1828
by: luna | last post by:
trying to create an update/insert button basically if the record exists in the database i want to do an update if it doesnt exist i want to create a new record using insert all using the same button my code (which is a mess from playing around!) (this is a test page im playing with) ID in the database is auto increment just cant seem to...
4
5467
by: Chris Kratz | last post by:
Hello all, We have run into what appears to be a problem with rules and subselects in postgres 7.4.1. We have boiled it down to the following test case. If anyone has any thoughts as to why this would be happening, we would appreciate feedback. We have tested on 7.3.4, 7.3.6 and 7.4.1 and all exhibit the same behavior. Test case one...
2
4470
by: Eduardo Pérez Ureta | last post by:
How may I do a INSERT ON DUPLICATE KEY UPDATE like in mysql: http://dev.mysql.com/doc/mysql/en/INSERT.html ? Eduardo ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
3
7360
by: V T | last post by:
Hello all, SQL Server 2000 documentation http://www.microsoft.com/technet/prodtechnol/sql/2000/reskit/part10/c3761.mspx states that if view is using "NOT NULL" columns of a base table, then insert/update performed on a view must provide dummy values for those columns, and code of the trigger should ignore them. But I cannot reproduce...
0
342
by: Daniel | last post by:
update/insert with microsoft.xml.xquery(.net2.0beta) can anyone provide an example of how to update/insert with microsoft.xml.xquery?
3
1818
by: rhaazy | last post by:
Using ms sql 2000 I have 2 tables. I have a table which has information regarding a computer scan. Each record in this table has a column called MAC which is the unique ID for each Scan. The table in question holds the various scan results of every scan from different computers. I have an insert statement that works however I am having...
2
4794
by: technocraze | last post by:
Hi guys, I have encountered this error when updating the values to the MS Acess table. Error : Update on linked table failed. ODBC sql server error Timeout expired. MS Acess is my front end and sql server is my backend server. This error occured whenever i step through and when it reaches rs.update it jux hangs down there and thereafter...
1
2503
by: sridhar4554 | last post by:
How to give a grant like select,update,insert on a single table i had tried with the command grant eg:GRANT SELECT,INSERT,UPDATE ON DTS_OUTBOX_QUEUE TO sanpapps@dap1 IDENTIFIED BY 'disable'; where snapapps is the user name and dap1 is hostname. when i tried this its gving error incorrect table name.
0
7718
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7809
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6041
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1936
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.