mwm
01-25-2007, 03:14 PM
I have a simple form that updates customer info. On the page call cifcustedit.php there is a javascript calendar that pops to choose a date to be inserted into the db table. That works great. Here lies the problem:
1) If you just change the cdate by itself in goes into the table just fine, but when you change that along with another variable in the form it puts the cdate at the default of 00-00-0000.
2) Other times when another var is changed it echo's back the incorrect date ie. you put in from the calander 1-04-2007 and when echoed back in the form the next time you view it, it reads 04-20-2001?
I have no idea how to solve this, any help or suggestion is realy appreciated.
here is the code.
<?
session_start();
include "conn.php";
$id=$_POST['id'];
?>
<html>
<body><head></head>
<script language="javascript" src="http://xx.xx.xx/customer/cal2.js">
</script>
<body background="white" text= "#000000" link= "#A52A2A" vlink ="#A52A2A" alink= "#A52A2A"></body>
<form action="custeditupdate.php" method="POST" name = "cifcustedit" >
<h1><p align=center></p></h1>
<h2><p align=center>Edit Customer Information</p></
<h3></h3><pre><p align =center><a href="managerstart.php">Main</a>
</center></pre>
<font color=#A52A2A>*</font>Required
<hr>
<?
$query = ("SELECT id,custname,custadd,city,state,zip,custphone,workphone,cellphone,community,lot,DATE_FORMAT(cdate,'%m-%d-%Y') FROM customers where id = '$id' and community ='$community'");
$result = mysql_query($query);
$row=mysql_fetch_row($result);
echo "<input type = hidden name = id value ='$id'>";
?>
<br>
<h3>
<p align=center><font color=#A52A2A>*</font>Customer Name <input type="text" name="custname" value = "<? echo $row['1']?>" size=30 maxlength=30><font color=#A52A2A>*</font>Address <input type="text" name="custadd" value = "<? echo $row['2']?>" size=30 maxlength=30><font color=#A52A2A><p align = center>*</font>City <input type="text" name="city" value = "<? echo $row['3']?>" size=25 maxlength=25><font color=#A52A2A>*</font>State <input type="text" name="state" value = "<? echo $row['4']?>" size=2 maxlength=2><font color=#A52A2A>*</font>Zip <input type="text" name="zip" value = "<? echo $row['5']?>" size=5 maxlength=5><font color=#A52A2A><p align = center>*</font>Phone <input type="text" name="custphone" value = "<? echo $row['6']?>" size=12 maxlength=12>Work Phone <input type="text" name="workphone" value = "<? echo $row['7']?>" size=12 maxlength=12> Cell Phone <input type="text" name="cellphone" value = "<? echo $row['8']?>" size=12 maxlength=12><p align = center>
<font color=#A52A2A>*</font>Community <input type="text" name="community" value = "<? echo $row['9']?>" size=20 maxlength=20>
<font color=#A52A2A>*</font>Lot/Building <input type="text" name="lot" value = "<? echo $row['10']?>"size=10 maxlength=10></p><script language="javascript" src="http://69.212.88.203/customer/cal_conf2.js"></script>
<font color=#A52A2A><p align = center>*</font>Close Date <input type="text" name="cdate" value = "<?echo $row['11']?>" size="10"><a href="javascript:showCal('Calendar4')"> Select Date</a>
<br></center>
</h3>
<p> <input type=Submit name=Submit style="font-size:15" value="Update"> <p>
</form>
</body>
</html>
<?
session_start();
include ("conn.php");
echo "<pre>";
print_r($_POST);
echo "</pre>";
$query = "UPDATE customers Set community = '$community',custname ='$custname',custadd ='$custadd',city = '$city', state = '$state', zip ='$zip',custphone = '$custphone', workphone = '$workphone',cellphone = '$cellphone', lot= '$lot', cdate = '$cdate' WHERE id = '$id'";
$result = mysql_query($query) or die ("Could not Update");
echo "All records have been change for $custname";
?>
<html>
<center><h3>
<body background="white" "text= "#000000" link= "#A52A2A" vlink ="#A52A2A" alink= "#A52A2A">
</h3>
<p><a href="managerstart.php">Main</a></center>
</html>
1) If you just change the cdate by itself in goes into the table just fine, but when you change that along with another variable in the form it puts the cdate at the default of 00-00-0000.
2) Other times when another var is changed it echo's back the incorrect date ie. you put in from the calander 1-04-2007 and when echoed back in the form the next time you view it, it reads 04-20-2001?
I have no idea how to solve this, any help or suggestion is realy appreciated.
here is the code.
<?
session_start();
include "conn.php";
$id=$_POST['id'];
?>
<html>
<body><head></head>
<script language="javascript" src="http://xx.xx.xx/customer/cal2.js">
</script>
<body background="white" text= "#000000" link= "#A52A2A" vlink ="#A52A2A" alink= "#A52A2A"></body>
<form action="custeditupdate.php" method="POST" name = "cifcustedit" >
<h1><p align=center></p></h1>
<h2><p align=center>Edit Customer Information</p></
<h3></h3><pre><p align =center><a href="managerstart.php">Main</a>
</center></pre>
<font color=#A52A2A>*</font>Required
<hr>
<?
$query = ("SELECT id,custname,custadd,city,state,zip,custphone,workphone,cellphone,community,lot,DATE_FORMAT(cdate,'%m-%d-%Y') FROM customers where id = '$id' and community ='$community'");
$result = mysql_query($query);
$row=mysql_fetch_row($result);
echo "<input type = hidden name = id value ='$id'>";
?>
<br>
<h3>
<p align=center><font color=#A52A2A>*</font>Customer Name <input type="text" name="custname" value = "<? echo $row['1']?>" size=30 maxlength=30><font color=#A52A2A>*</font>Address <input type="text" name="custadd" value = "<? echo $row['2']?>" size=30 maxlength=30><font color=#A52A2A><p align = center>*</font>City <input type="text" name="city" value = "<? echo $row['3']?>" size=25 maxlength=25><font color=#A52A2A>*</font>State <input type="text" name="state" value = "<? echo $row['4']?>" size=2 maxlength=2><font color=#A52A2A>*</font>Zip <input type="text" name="zip" value = "<? echo $row['5']?>" size=5 maxlength=5><font color=#A52A2A><p align = center>*</font>Phone <input type="text" name="custphone" value = "<? echo $row['6']?>" size=12 maxlength=12>Work Phone <input type="text" name="workphone" value = "<? echo $row['7']?>" size=12 maxlength=12> Cell Phone <input type="text" name="cellphone" value = "<? echo $row['8']?>" size=12 maxlength=12><p align = center>
<font color=#A52A2A>*</font>Community <input type="text" name="community" value = "<? echo $row['9']?>" size=20 maxlength=20>
<font color=#A52A2A>*</font>Lot/Building <input type="text" name="lot" value = "<? echo $row['10']?>"size=10 maxlength=10></p><script language="javascript" src="http://69.212.88.203/customer/cal_conf2.js"></script>
<font color=#A52A2A><p align = center>*</font>Close Date <input type="text" name="cdate" value = "<?echo $row['11']?>" size="10"><a href="javascript:showCal('Calendar4')"> Select Date</a>
<br></center>
</h3>
<p> <input type=Submit name=Submit style="font-size:15" value="Update"> <p>
</form>
</body>
</html>
<?
session_start();
include ("conn.php");
echo "<pre>";
print_r($_POST);
echo "</pre>";
$query = "UPDATE customers Set community = '$community',custname ='$custname',custadd ='$custadd',city = '$city', state = '$state', zip ='$zip',custphone = '$custphone', workphone = '$workphone',cellphone = '$cellphone', lot= '$lot', cdate = '$cdate' WHERE id = '$id'";
$result = mysql_query($query) or die ("Could not Update");
echo "All records have been change for $custname";
?>
<html>
<center><h3>
<body background="white" "text= "#000000" link= "#A52A2A" vlink ="#A52A2A" alink= "#A52A2A">
</h3>
<p><a href="managerstart.php">Main</a></center>
</html>