473,397 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

ADD/EDIT/DELETE ALL RUNNING at same time

232 100+
this is just a simple form
department log in
a page displays employees
on this page you may add edit delete employee
but the problem is that my add/edit/delete all option are running at same time even after passing correct variables
please help
homedisp.php
Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2. <HEAD>
  3. <TITLE="cccc SALARY">
  4. <?php 
  5. SESSION_START();
  6. include ("conn.php");
  7. include ("HEADER.php");
  8. //exit;
  9. IF (ISSET($_SESSION['deptno']))
  10. {
  11. //$deptno="";$RS="";
  12. $deptno=$_SESSION['deptno'];
  13. //ECHO $deptno;
  14. //EXIT;
  15.             $qi="SELECT * FROM PAYMST WHERE DEPTno=$deptno";
  16.             $RESULT=mysqli_query($conn,$qi);
  17.  
  18. //$CONN->CLOSE();
  19. echo "<BODY>";
  20. echo "<TABLE BORDER='1'>";
  21. echo "<TH>cccc SALARY INFORMATION UPDATE</TH>";
  22. WHILE($RS=MYSQLI_FETCH_ARRAY($RESULT))
  23. {
  24. ?>
  25.  
  26. <TR><TD><?PHP ECHO $RS['ECODE'] ?></TD><TD><?PHP ECHO $RS['NAME'] ?></TD><TD><A HREF='INDEX.PHP?STRACTION=ADD'>ADD</A></TD>
  27. <TD><A HREF="INDEX.PHP?STRACTION=EDIT & ECODE=<?PHP ECHO $RS['ECODE'] ?>">EDIT</A></TD>
  28. <TD><A HREF="INDEX.PHP?STRACTION=DELETE & ECODE=<?PHP ECHO $RS['ECODE'] ?>">DELETE</A></TD></TR>
  29.  
  30. <?PHP
  31. }
  32. }
  33. ELSE
  34. {
  35.     ECHO "<META HTTP-EQUIV='REFRESH' CONTENT='0 URL=SALLOGIN.PHP'>";
  36. }
  37. ?>
  38. </TABLE>
  39. </BODY>
  40. </TITLE>
  41. </HEAD>
  42. </HTML>
  43.  
  44.  
  45.  
index.php
Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2. <HEAD>
  3. <TITLE="cccc SALARY">
  4. <?php 
  5. SESSION_START();
  6. include ("conn.php");
  7. include ("HEADER.php");
  8. //$STRACTION="";
  9. $ECODE=$NAME="";
  10. //exit;
  11. IF (ISSET($_SESSION["deptno"]))
  12. {
  13.     $DEPTNO=$_SESSION["deptno"];
  14.  
  15. IF(ISSET($_GET["STRACTION"]))
  16.     {
  17.         //ECHO "hhhh";
  18.         //EXIT;    
  19.         $STRACTION=$_GET["STRACTION"];
  20.         ECHO $STRACTION;
  21.       // EXIT;        
  22.     }
  23.  
  24. IF($_SERVER["REQUEST_METHOD"]="POST" AND ISSET($_POST["SUBMIT"]))
  25. {
  26.  
  27. FUNCTION TESTINPUT($DATA)
  28. {
  29.     $DATA=TRIM($DATA);
  30.     $DATA=STRIPSLASHES($DATA);
  31.     $DATA=HTMLSPECIALCHARS($DATA);
  32.     RETURN $DATA;
  33. }
  34.     $ECODE=TESTINPUT($_POST["TXTECODE"]);
  35.     $NAME=TESTINPUT($_POST["TXTNAME"]);
  36.  
  37.         IF ($STRACTION="ADD")
  38.         {
  39.             $qi="INSERT INTO PAYMST (ECODE,NAME,DEPTNO) VALUES ('$ECODE','$NAME',$DEPTNO)";
  40.  
  41.             IF($result=mysqli_query($conn,$qi))
  42.         {
  43.             ECHO "<br/> VALUE INSERTED SUCCESSFULLY";
  44.         }
  45.  
  46.         }
  47.         IF ($STRACTION="EDIT")
  48.         {
  49.  
  50.             $qi="UPDATE PAYMST SET NAME='$NAME' WHERE ECODE='$ECODE' ";
  51.  
  52.             IF(mysqli_query($conn,$qi))
  53.         {
  54.             ECHO "<br/> VALUE UPDATED SUCCESSFULLY";
  55.         }
  56.  
  57.         }
  58.         IF ($STRACTION="DELETE")
  59.         {
  60.             $qi="DELETE FROM PAYMST WHERE ECODE='$ECODE' ";
  61.  
  62.             IF(mysqli_query($conn,$qi))
  63.         {
  64.             ECHO "<br/> VALUE DELETED SUCCESSFULLY";
  65.         }
  66.  
  67.         }
  68.  
  69. //$CONN->CLOSE();
  70.  
  71. }
  72.    IF ($STRACTION="EDIT")
  73.         {
  74.             if(isset($_GET['ECODE']))
  75.             {
  76.                 echo "hhhh";
  77.                 //exit;
  78.             $ECODE=$_GET['ECODE'];
  79.             }
  80.             $qi="SELECT * FROM PAYMST WHERE ECODE='$ECODE'";
  81.  
  82.             IF($RESULT=mysqli_query($conn,$qi))
  83.          {
  84.             WHILE($RS=MYSQLI_FETCH_ARRAY($RESULT))
  85.             {
  86.                 $ECODE=$RS['ECODE'];
  87.                 $NAME=$RS['NAME'];
  88.             }
  89.  
  90.          }
  91.         }
  92.     else    
  93.         {
  94.             $ECODE="";
  95.             $NAME="";
  96.         }
  97.  
  98. ?>
  99. <BODY>
  100. <form name="a" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
  101. <TABLE>
  102. <TH>cccc SALARY INFORMATION UPDATE</TH>
  103. <TR><TD>ECODE</TD><TD><INPUT TYPE="TEXT" NAME="TXTECODE" VALUE="<?PHP ECHO $ECODE; ?>"></TD></TR>
  104. <TR><TD>NAME</TD><TD><INPUT TYPE="TEXT" NAME="TXTNAME" VALUE="<?PHP ECHO $NAME; ?>"></TD></TR>
  105. <TR><TD><INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="SUBMIT"></TD></TR>
  106.  
  107. </form>
  108. <?PHP
  109. }
  110.  
  111. ELSE
  112. {
  113.     ECHO "<META HTTP-EQUIV='REFRESH' CONTENT='0 URL=SALLOGIN.PHP'>";
  114. }
  115. ?>
  116. </TABLE>
  117. </BODY>
  118. </TITLE>
  119. </HEAD>
  120. </HTML>
  121.  
  122.  
  123.  
Feb 8 '15 #1
1 1217
Claus Mygind
571 512MB
Your using a single = instead of ==. The result you are setting the value of the variable instead of testing the value of the variable
Expand|Select|Wrap|Line Numbers
  1.  IF ($STRACTION="ADD")
  2.  
this should be
Expand|Select|Wrap|Line Numbers
  1.  IF ($STRACTION=="ADD")
  2.  
also I would get rid of the blank space in the anchor link
Expand|Select|Wrap|Line Numbers
  1.  <TD><A HREF="INDEX.PHP?STRACTION=EDIT&ECODE=<?PHP ECHO $RS['ECODE'];?>">EDIT</A></TD> 
  2.  
Feb 16 '15 #2

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

Similar topics

1
by: Jeremy | last post by:
I have built a form that calls queries. I have the first 2 set up as select queries, and the third set up as a make table query. When multiple users are on this application at the same time, they...
1
by: Qnavry | last post by:
I am creating one page to edit, delete, and add data to a database. The Add code works but the Edit and Delete do not. What am I doing wrong? If you need more code let me know. Thanks Code:...
4
by: Smudger | last post by:
I've succesfully connected my MS Access Database to my .NET app and can view / navigate records. What I would like to do now though is perform add, edit & delete functions on these records is...
12
by: dennist685 | last post by:
Can't edit, delete or add row in an Access database in a website 2003 When I implement a walkthrough using Northwind I have no trouble doing this. Also, in a windowsforms project I have no...
1
by: Darryl | last post by:
I have an Access 2003 front-end tied via ODBC to a SQL Anywhere 8 back-end. When I open a table & try to delete a record in a certain table, I get: "The Microsoft Jet database engine stopped...
2
subashini Thiyagarajan
by: subashini Thiyagarajan | last post by:
hi, i want to delete a record.hope it is very easy.but same time i want to move the deleted record in to new table for report generation in future. i succeeded in deleting the record along with...
1
by: abhi81 | last post by:
Hello All, I have a table on which I have created a insert,Update and a Delete trigger. All these triggers write a entry to another audit table with the unique key for each table and the timestamp....
0
by: TT | last post by:
Hello. I'm working in asp.net and i need to disable the edit/delete functionality from a frmview component. help me.thang you! my ACL sub: Protected Sub Page_Load(ByVal sender As Object,...
2
by: =?Utf-8?B?SWJyYWhpbS4=?= | last post by:
Hello, I have a client c# application from which I want to Add/Edit/Delete & list records by connecting to Web Service. HOw can I write classes & methods in Web service projet that will : ...
0
by: magnolia | last post by:
i created a trigger that will record the changes made to a table .everything works fine except the insert query.whenerever i try to insert a record it fires insert and update triger at the same time...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.