469,927 Members | 1,940 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

date format

I have the following script that use for the following after i have made my search for a name in my database. I select the name and it bring up this from with all the information of the person. It works great up to the point of the date entries.
It will bring up the fromat date ok, but when I try and change it and head the submit buton it wipes out the database information. The database stores the information like yyyy-mm-dd hh:mm:ss. I have it fromat to show as month day Year. As long as i re-enter the date as yyy-mm-dd hh:mm:dd it will load the information and the next it is load it show the month day and year and as long as I don't try and change any thing it is fine.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. // PHP DB Control Panel
  4. //
  5. include("cn.php");
  6. include("common.php");
  7. checklogin();
  8.  
  9. $msg = "";
  10. $no = "";
  11. $lastname = "";
  12. $firstname = "";
  13. $address = "";
  14. $city = "";
  15. $state = "";
  16. $postal_code = "";
  17. $zip = "";
  18. $country = "";
  19. $phone_number = "";
  20. $fax_number = "";
  21. $car_phone = "";
  22. $internet_address = "";
  23. $status = "";
  24. $type = "";
  25. $expiration_date = "";
  26. $begin_date = "";
  27. $hold_until_date = "";
  28. $hold_from_date = "";
  29. $refund = "";
  30. $internet = "";
  31.  
  32. if(isset($_POST['Submit']))
  33. {
  34.     $lastname = $_POST['Last_Name'];
  35.     $firstname = $_POST['First_Name'];
  36.         $address = $_POST['Address_1']; 
  37.         $city = $_POST['City']; 
  38.         $state = $_POST['State'];
  39.         $postal_code = $_POST['Postal_Code']; 
  40.         $zip = $_POST['Zip'];
  41.         $country = $_POST['Country']; 
  42.         $phone_number = $_POST['Phone_number']; 
  43.         $fax_number = $_POST['Fax_number']; 
  44.         $car_phone = $_POST['Car_phone']; 
  45.         $internet_address = $_POST['Internet_address']; 
  46.         $status = $_POST['Status']; 
  47.         $type = $_POST['Type'];
  48.         $begin_date = $_POST['Begin_Date']; 
  49.         $expiration_date = $_POST['Expiration_Date'];
  50.         $hold_from_date = $_POST['Hold_From_Date'];
  51.         $hold_until_date = $_POST['Hold_Until_Date']; 
  52.         $refund = $_POST['Refund']; 
  53.         $internet = $_POST['Internet'];  
  54.  
  55.     if(!isset($_GET['Subscription_Number']))
  56.     {
  57.                 $result = mysql_query("Insert into subscriber_information(`Subscription_Number`,`Last_Name`,`First_Name`,`Address_1`,`City`,`State`,`Postal_Code`,`Zip`,`Country`,`Phone_number`,`Fax_number`,`Car_phone`,`Internet_address`,`Status`,`Type`,`Begin_Date`,`Expiration_Date`,`Hold_From_Date`,`Hold_Until_Date`,`Refund`,`Internet`) values('$lastname','$firstname','$address','$city','$state','$postal_code','$zip','$country','$phone_number','$fax_number','$car_number','$internet_address','$status','$type','$expiration_date','$begin_date','$hold_until_date','$hold_from_date','$refund','$internet')");
  58.                 if(!$result)
  59. {
  60.  
  61.     $msg = 'Error while updating: ' . mysql_error() . "<br />\n";
  62.     die($msg);
  63. }
  64. else
  65. {
  66.     $msg = "Record is saved";
  67. }
  68.  
  69.     }
  70.     else
  71.     {
  72.         $result = mysql_query("Update subscriber_information set `Last_Name`='$lastname', `First_Name`='$firstname', `Address_1`='$address', `City`='$city', `State`='$state', `Postal_Code`='$postal_code', `Zip`='$zip', `Country`='$country', `Phone_number`='$phone_number', `Fax_number`='$fax_number', `Car_phone`='$car_phone', `Internet_address`='$internet_address', `Status`='$status', `Type`='$type', `Begin_Date`='$begin_date', `Expiration_Date`='$expiration_date', `Hold_From_Date`='$hold_from_date', `Hold_Until_Date`='$hold_until_date', `Refund`='$refund', `Internet`='$internet' where Subscription_Number =".$_GET['Subscription_Number']);
  73.                 if(!$result)
  74. {
  75.  
  76.     $msg = 'Error while updating: ' . mysql_error() . "<br />\n";
  77.     die($msg);
  78. }
  79. else
  80. {
  81.     $msg = "Record is updated";
  82. }
  83.  
  84.     }
  85. }
  86. if(isset($_GET['Subscription_Number']))
  87. {
  88.     $result = mysql_query("Select * From subscriber_information where Subscription_Number=".$_GET['Subscription_Number'],$link) or die (mysql_error());
  89.     while ($row = mysql_fetch_array($result, MYSQL_BOTH)){
  90.     $lastname = $row['Last_Name'];
  91.     $firstname = $row['First_Name'];
  92.         $address = $row['Address_1']; 
  93.         $city = $row['City']; 
  94.         $state = $row['State'];
  95.         $postal_code = $row['Postal_Code']; 
  96.         $zip = $row['Zip']; 
  97.         $country = $row['Country']; 
  98.         $phone_number = $row['Phone_number']; 
  99.         $fax_number = $row['Fax_number']; 
  100.         $car_phone = $row['Car_phone']; 
  101.         $internet_address = $row['Internet_address']; 
  102.         $status = $row['Status']; 
  103.         $type = $row['Type'];
  104.         $date = mysql_query("SELECT DATE_FORMAT(Begin_Date, '%M %D %Y')as Begin_Date FROM subscriber_information where Subscription_Number=".$_GET['Subscription_Number'],$link) or die (mysql_error());
  105.         while ($row = mysql_fetch_array($date, MYSQL_BOTH)) {
  106.         $begin_date = $row['Begin_Date'];   
  107.         $date2 = mysql_query("SELECT DATE_FORMAT(Expiration_Date, '%M %D %Y')as Expiration_Date FROM subscriber_information where Subscription_Number=".$_GET['Subscription_Number'],$link) or die (mysql_error());
  108.         while ($row = mysql_fetch_array($date2, MYSQL_BOTH)) {
  109.         $expiration_date = $row['Expiration_Date'];   
  110.         $date3 = mysql_query("SELECT DATE_FORMAT(Hold_From_Date, '%M %D %Y')as Hold_From_Date FROM subscriber_information where Subscription_Number=".$_GET['Subscription_Number'],$link) or die (mysql_error());
  111.         while ($row = mysql_fetch_array($date3, MYSQL_BOTH)) {
  112.         $hold_from_date = $row['Hold_From_Date'];   
  113.         $date4 = mysql_query("SELECT DATE_FORMAT(Hold_Until_Date, '%M %D %Y')as Hold_Until_Date FROM subscriber_information where Subscription_Number=".$_GET['Subscription_Number'],$link) or die (mysql_error());
  114.         while ($row = mysql_fetch_array($date4, MYSQL_BOTH)) {
  115.         $hold_until_date = $row['Hold_Until_Date'];   
  116.         $refund = $row['Refund']; 
  117.         $internet = $row['Internet'];
  118.  
  119. }
  120.  
  121. }
  122. ?>
  123. <html>
  124. <head>
  125. <title>Admin</title>
  126. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  127. </head>
  128.  
  129. <body>
  130. <h3>New/Edit Record</h3>
  131. <p><a href="listrecord.php">List Records</a><br>
  132.   <a href="admin.php">Main</a></p>
  133. <p><?php echo $msg?><br><?php echo $result?></P>
  134. <form name="form1" method="post" action="">
  135.   <p>&nbsp;</p>
  136.   <table border="1" align="center" cellpadding="0" cellspacing="0">
  137.  
  138.     <tr>
  139.         <td>Last Name:<input name="Last_Name" type="text" id="Last_Name" value="<?php echo $lastname?>">First Name:<input name="First_Name" type="text" id="First_Name" value="<?php echo $firstname?>"></td>
  140.     </tr>
  141.     <tr> 
  142.         <td>Address:<input name="Address_1" type="text" id="Address_1" value="<?php echo $address?>"></td>
  143.     </tr>
  144.     <tr> 
  145.         <td>City:<input name="City" type="text" id="City" value="<?php echo $city?>">State:<input name="State" type="text" id="State" value="<?php echo $state?>"></td>
  146.     </tr>
  147.     <tr> 
  148.         <td>Postal Code:<input name="Postal_Code" type="text" id="Postal_Code" value="<?php echo $postal_code?>">Zip:<input name="Zip" type="text" id="Zip" value="<?php echo $zip?>"></td>
  149.     </tr>
  150.     <tr> 
  151.         <td>Country:<input name="Country" type="text" id="Country" value="<?php echo $country?>">Phone number:<input name="Phone_number" type="text" id="Phone_number" value="<?php echo $phone_number?>"></td>
  152.     </tr>
  153.     <tr> 
  154.         <td>Fax Number:<input name="Fax_number" type="text" id="Fax_number" value="<?php echo $fax_number?>">Car phone:<input name="Car_phone" type="text" id="Car_phone" value="<?php echo $car_phone?>"></td>
  155.     </tr>
  156.     <tr> 
  157.         <td>Internet address:<input name="Internet_address" type="text" id="Internet_address" value="<?php echo $internet_address?>"></td>
  158.     </tr>
  159.     <tr> 
  160.         <td>Status:<input name="Status" type="text" id="Status" value="<?php echo $status?>">Type:<input name="Type" type="text" id="Type" value="<?php echo $type?>"></td>
  161.     </tr>
  162.     <tr> 
  163.         <td>Begin Date:<input name="Begin_Date" type="text" id="Begin_Date" value="<?php echo $begin_date?>">Expiration Date:<input name="Expiration_Date" type="text" id="Expiration_Date" value="<?php echo $expiration_date?>"></td>
  164.     </tr>
  165.     <tr> 
  166.         <td>Hold From Date:<input name="Hold_From_Date" type="text" id="Hold_From_Date" value="<?php echo $hold_from_date?>">Hold Until Date:<input name="Hold_Until_Date" type="text" id="Hold_Until_Date" value="<?php echo $hold_until_date?>"></td>
  167.     </tr>
  168.     <tr> 
  169.         <td>Refund:<input name="Refund" type="text" id="Refund" value="<?php echo $refund?>">Internet:<input name="Internet" type="text" id="Internet" value="<?php echo $internet?>"></td> 
  170.     </tr>
  171.     <tr> 
  172.       <td>&nbsp;</td>
  173.  
  174.       <td><input type="submit" name="Submit" value="Submit">
  175.         <input type="reset" name="Submit2" value="Reset"></td>
  176.     </tr>
  177.   </table>
  178.   <p>&nbsp; </p>
  179.   <p>&nbsp;</p>
  180. </form>
  181. <p><a href="admin.php">Main</a></p>
  182.  
  183. </body>
  184. </html>
  185.  
Sep 4 '06 #1
0 2587

Post your reply

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

Similar topics

15 posts views Thread by Simon Brooke | last post: by
4 posts views Thread by Richard Hollenbeck | last post: by
5 posts views Thread by Macca | last post: by
12 posts views Thread by Assimalyst | last post: by
20 posts views Thread by andreas | last post: by
30 posts views Thread by fniles | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.