Jump to content

multi action submit form (variable issue?)


nickelus

Recommended Posts

ok what we have here is a multi action submit form where on "submit update" the updated field appears to update however the rest get reset my guess is i'm losing some variables on update (i think) but this is my first time trying multi submit options and i'm not seeing the problem

<?php include"crm_main.php";
include "bio.php";mysql_select_db($database_bio);
if(isset($_POST['id'])){
$id=$_POST['id'];
}
if(isset($_POST['dsp_id'])){
		$dsp_id=$_POST['dsp_id'];
$dsp="SELECT * FROM dispute WHERE dsp_id='$dsp_id'";
$qry=mysql_query($dsp);
while($row=mysql_fetch_array($qry)){
	$dsp_id=$row[0];
	$id=$row[1];
	$open_dt=$row[2];
	$closed_dt=$row[3];
	$compt=$row['4'];
	$present=$row['5'];
	$empty=$row['6'];
	$moved=$row['7'];
	$dsp_notes=$row['8'];
	}
}
if(isset($_POST['enter'])){
$open_dt= date("Y-m-d");
if(isset($_POST['present'])){
	$present="Yes";
	}else{
		$present="No";
		}
if(isset($_POST['empty'])){
	$empty="Yes";
	}else{
		$empty="No";
		}
if(isset($_POST['moved'])){
	$moved="Yes";
	}else{
		$moved="No";
		}
$compt=$_POST['competitor'];
$dsp_notes=$_POST['dsp_notes'];
$dspEnter="INSERT 
INTO `dispute` (`client_id`, `open_dt`, 
			`competitor`,`present`, `empty`, `moved`, `dsp_notes`) 
VALUES ('$id', '$open_dt', '$compt','$present', '$empty', '$moved', '$dsp_notes');";
$disputeAction=mysql_query($dspEnter);
}
if(isset($_POST['update'])){
$dsp_id=$_POST['dsp_id'];
$closed_dt= date("Y-m-d");
if(isset($_POST['present'])){
	$present="Yes";
	}else{
		$present="No";
		}
if(isset($_POST['empty'])){
	$empty="Yes";
	}else{
		$empty="No";
		}
if(isset($_POST['moved'])){
	$moved="Yes";
	}else{
		$moved="No";
		}
$compt=$_POST['competitor'];
$dsp_notes=$_POST['dsp_notes'];
$dspEnter="UPDATE `dispute` SET `competitor`=$compt,`present`=$present, `empty`=$empty, `moved`=$moved, `dsp_notes=$dsp_notes` WHERE `dsp_id`=$dsp_id;";
$disputeAction=mysql_query($dspEnter);
}
if(isset($_POST['closed'])&&($_POST['closed']=="Close")){
$dsp_id=$_POST['dsp_id'];
$closed_dt= date("Y-m-d");
$dspEnter="UPDATE `dispute` SET `closed_dt`=$closed_dt WHERE `dsp_id`=$dsp_id";
$disputeAction=mysql_query($dspEnter);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dispute Console</title>
<link href="/sitetest/biodiesel/stylized.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div align="center"> <div id="stylized h1">Dispute Console</div><br/><form action="edit_dispute.php" method="post" name="dispute">
  <table width="200" border="0" align="center">
    <tr>
      <td>Disp ID</td>
      <td> </td>
      <td><?php if (isset($dsp_id)){echo $dsp_id;}?></td>
    </tr>
    <tr>
      <td>Date Opened</td>
      <td> </td>
      <td><?php if (isset($open_dt)){echo $open_dt;}?></td>
      </tr>
    <tr>
      <td>Date Closed</td>
      <td> </td>
      <td><?php if(isset($closed_dt)){echo $closed_dt;}?></td>
      </tr>
    <tr>
    <td>Empty</td>
    <td><input name="empty" type="checkbox" <?php if(isset($empty)&&($empty=="Yes")){echo 'checked';}?>></td>
    <td>:</td>
    </tr>
  <tr>
    <td>Moved</td>
    <td><input name="moved" type="checkbox" <?php if(isset($moved)&&($moved=="Yes")){echo "checked";}?>></td>
    <td> </td>
    </tr>
  <tr>
    <td>Present</td>
    <td><input name="present" type="checkbox" <?php if(isset($present)&&($present=="Yes")){echo "checked";}?>></td>
    <td> </td>
    </tr>
  <tr>
    <td>Competitor</td>
    <td><input name="client_id" type="hidden" value="<?php if(isset($id)){echo $id;}?>" /></td>
    <td><select name="competitor">
      <option selected>(Select One)</option>
      <option value="Darling" <?php if(isset($compt)&&($compt=="Darling")){print "selected";}?>>Darling</option>
      <option value="Baker"<?php if(isset($compt)&&($compt=="Baker")){echo "selected";}?>>Baker</option>
      <option value="United"<?php if(isset($compt)&&($compt=="United")){echo "selected";}?>>United</option>
      <option value="Other"<?php if(isset($compt)&&($compt=="Other")){echo "selected";}?>>Other</option>
    </select></td>
    </tr>
  <tr>
    <td>Notes</td>
    <td><input name="dsp_id" type="hidden" value="<?php if(isset($dsp_id)){echo $dsp_id;}?>" /></td>
    <td><textarea name="dsp_notes" cols="35" rows="3" wrap="physical" >
   <?php if(isset($dsp_notes)){echo "$dsp_notes";}?>
    </textarea></td>
    </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td><input name="enter" type="submit" value="Enter" />
      <input name="update" type="submit" value="Update" />
      <input name="closed" type="submit" value="Close" /></td>
    <td> </td>
  </tr>
  </table>
</form></div>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/166725-multi-action-submit-form-variable-issue/
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.