By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,501 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,501 IT Pros & Developers. It's quick & easy.

I want to save newpassword into database

P: 10
Expand|Select|Wrap|Line Numbers
  1.  
  2. <html>
  3.  
  4. <head>
  5.   <style type="text/css">
  6.   h2{color:#A02820}
  7.   </style>
  8.  
  9. </head>
  10.  
  11. <script language=javascript>
  12.  function fnNew_Retype_Pswd()
  13.         {
  14.               var pass1 = document.useredit.txtEmployeeNewPassword.value;
  15.               var pass2 = document.useredit.txtEmployeeRetypePassword.value;
  16.  
  17.                  if(document.useredit.txtEmployeeNewPassword.value =="")
  18.                 {
  19.                         alert("Please Enter New Password...");
  20.                         //useredit.txtEmployeeNewPassword.focus();
  21.                         return false;
  22.                 }
  23.  
  24.                 else if(document.useredit.txtEmployeeNewPassword.value.length < 6)
  25.                 {
  26.                         alert("Your New Password Length Should Be 6 Characters...");
  27.                         return false;
  28.                 //      useredit.txtEmployeeNewPassword.value = "";
  29.  
  30.                 }
  31.  
  32.                 else  if(document.useredit.txtEmployeeRetypePassword.value =="")
  33.                 {
  34.                         alert("Please Enter Retype Password...");
  35.                         return false;
  36.                 }
  37.  
  38.                 else if(document.useredit.txtEmployeeRetypePassword.value.length < 6)
  39.                 {
  40.                         alert("Your Retype Password Length Should Be 6 Characters..."); alert("Your Retype Password Length Should Be 6 Characters...");
  41.                         useredit.txtEmployeeRetypePassword.value = "";
  42.                 }
  43.  
  44.                 else if(pass1 != pass2)
  45.                 {
  46.                         alert("Your New Password Did Not Match With The Retype Password.. ");
  47.                          event.returnValue = false;
  48.  
  49.                 }
  50.  
  51.                 function fnSave()
  52.                 {
  53.                         if( fnNew_Retype_Pswd()== false)
  54.                         {
  55.                         event.returnValue = true;
  56.                         }
  57. }
  58. <?php
  59.  
  60.  
  61.         $code = $_GET['code'];
  62.         $name = "";
  63.         $desg = "";
  64.    $weeklyoff = "";
  65.          $doj = "";
  66.  $activatedon = "";
  67. $passwordexpireson = "";
  68.  
  69.                 $dbconnect=pg_connect("host=10.10.2.12 dbname=punch_system  user=postgres password=postgres") or
  70.          die("could not connect to the database");
  71.  
  72.         $query = "select pmt19_emp_code,pmt19_activatedon,pmt19_passwordexpireon,";
  73.         $query = $query . " pmt06_emp_code,pmt06_emp_name,pmt06_desg_code,pmt06_date_of_join,";
  74.         $query = $query . " pmt06_weekly_off,pmt12_desg_code,pmt12_desg_desc";
  75.         $query = $query . " from  pmt_web_users,pmt_employee,pmt_designation ";
  76.         $query = $query . "where pmt19_emp_code=pmt06_emp_code and pmt12_desg_code=pmt06_desg_code";
  77.         $query = $query . " and  pmt19_emp_code   = '" . $code . "'";
  78.  
  79.  
  80.  
  81.          $rs = pg_query($query)
  82.                       or die('Could not Open Recordset...') . pg_last_error($rs);
  83.  
  84.  
  85.          if (pg_num_rows($rs) > 0)
  86.  {
  87.                         $row = pg_fetch_row($rs);
  88.  
  89.                         $code = $_GET['code'];
  90.                         $name = $row[4];
  91.                         $desg = $row[9];
  92.                          $doj = $row[6];
  93.                    $weeklyoff = $row[7];
  94.                  $activatedon = $row[1];
  95.            $passwordexpireson = $row[2];
  96.  
  97.                 }
  98.                  pg_free_result($rs);
  99.                  pg_close($dbconnect);
  100.  
  101. ?>
  102.  
  103.  
  104.  
  105.         <body bgcolor="#F0F0F0 ">
  106.          <h2 align=center>User Edit Information </h2>
  107.         <form name=useredit method=post action="" onsubmit=fnSave() >
  108.         <br><center>
  109.         <fieldset style='width:50%'><legend>User Edit Data</legend>
  110.         <table align=center cellspacing=2 cellpadding=2 bgcolor=FFFFCC >
  111.         <tr>
  112.           <td align=right>
  113.                  <font face="Garamond" size=3><b>
  114.                      Employee Code :
  115.                     </b></font>
  116.                     </td>
  117. <td>
  118.                      <font face="Garamond" size=2><b>
  119.                     <input  title  = "Specify Employee Code..."
  120.                          style     = "WIDTH: 100px; HEIGHT: 21px"
  121.                          maxLength = 7
  122.                          align     = left
  123.                                 id = txtEmployeeCode
  124.                          name      = txtEmployeeCode
  125.                          tabindex  = 1 readonly
  126.                          value     = "<? echo $code ?>">
  127.             </b></font> </td>
  128.  
  129.               <td align=right>
  130.                  <font face="Garamond" size=3><b>
  131.                       Employee Name :
  132.                        </b></font>
  133.                       </td>
  134.  
  135.                       <td align=left>
  136.                         <font face="Garamond" size=4><b>
  137.                          <input  title     = "Specify Employee Name..."
  138.                                  style     = "WIDTH: 100px; HEIGHT: 21px"
  139.                                  maxLength = 7
  140.                                  align     = left
  141.                                  id        = txtEmployeeName
  142.                                  name      = txtEmployeeName
  143.                                  tabindex  = 1 readonly
  144.                                  value     = "<? echo $name ?>">
  145.              </b></font> </td></tr>
  146.  <tr>
  147.            <td align=right>
  148.             <font face="Garamond" size=3><b>
  149.                Employee Desig:
  150.            </b></font> </td>
  151.  
  152.             <td align=right>
  153.                 <font face="Garamond" size=4><b>
  154.                 <input  title     = "Specify Employee Desig..."
  155.                         style     = "WIDTH: 100px; HEIGHT: 21px"
  156.                         maxLength = 7
  157.                         align     = left
  158.                         id        = txtEmployeeDesig
  159.                         name      = txtEmployeeDesig
  160.                         tabindex  = 1 readonly
  161.                         value     = "<? echo $desg?>">
  162.               </b></font> </td>
  163.  
  164.          <td align=right>
  165.              <font face="Garamond" size=3><b>
  166.                   Weeklyoff:
  167.                  </b></font> </td>
  168.  
  169.                   <td align=left>
  170.                       <font face="Garamond" size=4><b>
  171.                       <input  title     = "Specify Employee WeeklyOff..."
  172.                               style     = "WIDTH: 100px; HEIGHT: 21px"
  173.                               maxLength = 7
  174.                               align     = left
  175.                               id        = txtEmployeeWeeklyOff
  176.  name      = txtEmployeeWeeklyOff
  177.                               tabindex  = 1 readonly
  178.                               value     = "<?
  179.  
  180.                                                       if($weeklyoff == 1)
  181.                                                         {
  182.                                                         $weeklyoff = "Sunday";
  183.                                                         }
  184.                                                 else if($weeklyoff == 2)
  185.                                                         {
  186.                                                         $weeklyoff = "Monday";
  187.                                                         }
  188.                                                 else if($weeklyoff == 3)
  189.                                                         {
  190.                                                         $weeklyoff = "Tuesday";
  191.                                                         }
  192.                                                 else if($weeklyoff == 4)
  193.                                                         {
  194.                                                         $weeklyoff = "Wednesday";
  195.                                                         }
  196.                                                 else if($weeklyoff == 5)
  197.                                                         {
  198.                                                         $weeklyoff = "Thursday";
  199.                                                         }
  200.                                                 else if($weeklyoff == 6)
  201.                                                         {
  202.                                                         $weeklyoff = "Friday";
  203.                                                         }
  204.  
  205.                                                 else if($weeklyoff == 7)
  206.                                                         {
  207.  $weeklyoff = "Saturday";
  208.                                                         }
  209.  
  210.                                          echo $weeklyoff ?>">
  211.         </b></font> </td> </tr>
  212.  
  213.                  <tr><td><hr></td><td><hr></td><td><hr></td><td><hr></td></tr>
  214. <!--<HR NOSHADE="NOSHADE">-->
  215.         <tr>
  216.            <td align=right>
  217.               <font face="Garamond" size=3><b>
  218.                    Doj:
  219.                 </b></font></td>
  220.  
  221.                <td>
  222.                    <font face="Garamond" size=4><b>
  223.                        <input  title     = "Specify Employee Doj..."
  224.                                style     = "WIDTH: 100px; HEIGHT: 21px"
  225.                                maxLength = 7
  226.                                align     = left
  227.                                id        = txtEmployeeDoj
  228.                                name      = txtEmployeeDoj
  229.                                tabindex  = 1 readonly
  230.                                value     = "<? echo $doj ?>">
  231.                   </b></font> </td>
  232.  
  233.  
  234.         <td align=right> <font face="Garamond" size=3><b>
  235.                   Role:
  236.                     </b></font>
  237.           </td>
  238.  </td>
  239.  
  240.  
  241.         <td>
  242.     <select id=Role name=Role style="width: 100px"><option>[Select One]</option><?php fnRoles(); ?></select></td>
  243.        </tr>
  244.  
  245.  
  246.         <tr>
  247.                 <td align=left>
  248.                  <font face="Garamond" size=3><b>
  249.                    Current Password:
  250.                   </b></font> </td>
  251.  
  252.           <td>
  253.            <font face="Garamond" size=4><b>
  254.              <input  title     = "Specify Employee Current Password..."
  255.                      type      = password
  256.                      style     = "WIDTH: 100px; HEIGHT: 21px"
  257.                      maxLength = 7
  258.                      align     = left
  259.                      id        = txtEmployeeCurrentpassword
  260.                      name      = txtEmployeeCurrentPassword
  261.                      tabindex  = 1>
  262.                </b></font></td>
  263.  
  264.  
  265.          <td align=right> <font face="Garamond" size=3><b>
  266.                  Valid Compinies:
  267.                    </b></font> </td>
  268. <td>
  269.         <select name="ValidCompinies" id="Select1" size="4" multiple="multiple"
  270.          style="width: 180px"><option>[Select-One]</option><?php fnValidCompinies(); ?></select></tr>
  271.  
  272.         <tr>
  273.          <td align=right>
  274.            <font face="Garamond" size=3><b>
  275.                    New Password:
  276.                    </b></font> </td>
  277.  
  278.           <td>
  279.             <font face="Garamond" size=4><b>
  280.              <input  title     = "Specify Employee New Password..."
  281.                          type  = password
  282.                      style     = "WIDTH: 100px; HEIGHT: 21px"
  283.                      maxLength = 7
  284.                      align     = left
  285.                     id         = txtEmployeeNewpassword
  286.                      name      = txtEmployeeNewPassword
  287.                      tabindex  = 1 onfocusout=fnNew_Retype_Pswd() >
  288.                  </b></font>
  289.             </td></tr>
  290.  
  291.                 <tr>
  292.                    <td>
  293.                    <font face="Garamond" size=3><b>
  294.                          Retype Password:
  295.                        </b></font>
  296. <td>
  297.                     <font face="Garamond" size=4><b>
  298.                        <input  title     = "Specify Employee Retype Password..."
  299.                                type      = password
  300.                                style     = "WIDTH: 100px; HEIGHT: 21px"
  301.                                maxLength = 7
  302.                                align     = left
  303.                                id        = txtEmployeeRetypepassword
  304.                                name      = txtEmployeeRetypePassword onfocusout=fnNew_Retype_Pswd()
  305.                                tabindex  = 1>
  306.                         </b></font>
  307.                   </td></tr>
  308. <table align=center>
  309.         <tr><td>
  310.     <input type=submit value=Save id=Save name=Save style="width: 75px" onclick=fnPasswordSave()></td>
  311.         <td> <input type=Reset value=Reset id=reset name=reset style="width: 75px"></td>
  312.  
  313.          <td> <input type=button value=Close id=close name=close style="width: 75px" onclick='window.close()'>
  314.         </td></tr>
  315.         </table>
  316. <?php
  317.   function fnPasswordSave()
  318.          {
  319.  
  320.                        $code = $_GET['code'];
  321.                  $CurrentPwd = $_POST[' txtEmployeeCurrentPassword'];
  322.                  $NewPwd     = $_POST['txtEmployeeNewPassword'];
  323.                  $RetypePwd  = $_POST['txtEmployeeRetypePassword'];
  324.  
  325.          $dbconnect=pg_connect("host=10.10.2.12 dbname=punch_system  user=postgres password=postgres") or
  326.                  die("could not connect to the database");
  327.  
  328.  
  329.         $query = "update pmt_login_info set pmt19_password=$NewPwd where  pmt19_emp_code='" . $code . "'";
  330.                 echo $query;
  331.  
  332.                 $rs = pg_query($query) or die('Could not Open Recordset...') . pg_last_error($rs);
  333. if($rs)
  334.         {
  335.                 echo "Password Updated Successfully..";
  336.         }
  337.         else
  338.          {
  339.                 echo "Password Updation Unsuccessfull..";
  340.          }
  341.  
  342.         }
  343.  
  344.  
  345. ?>
  346. </form>
  347. </body>
  348. </html>

any one tell me,is my code correct to save newpassword into database.but output is not grtting.please,correct the code
Aug 5 '09 #1
Share this Question
Share on Google+
1 Reply


dlite922
Expert 100+
P: 1,584
are you getting any errors?
What have you done to debug so far? I can't run your code on my computer so you have to do some debugging and narrow down the issue.

Your SQL password field value does not have quotes around it. Put some quotes around that as well. You should be getting a SQL error though.



Dan
Aug 5 '09 #2

Post your reply

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