/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to DuggaSys/changePassword/index.php

  • Committer: gustav.hartvigsson at gmail
  • Date: 2013-04-03 11:52:56 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20130403115256-sz6zermzoom4lifc
Ignored .DS_Store files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
        header( "X-UA-Compatible: IE=edge,chrome=1" );
3
 
        $content = "password.html.php";
4
 
        $pagetitle = "Change password";
5
 
        
6
 
        // echo "<pre>";
7
 
        // print_r($_POST);
8
 
        // echo "</pre>";
9
 
        
10
 
        //Passwordchangingcode
11
 
        if( isset( $_POST['changePasswordSubmit'] )) {
12
 
                include '../../php/dbconnect.php';
13
 
                $queryString = "SELECT Student.ssn FROM Student WHERE Student.loginName=:LOGIN AND Student.passw=:PASSW;";
14
 
 
15
 
                $stmt = $pdo->prepare( $queryString );
16
 
                $stmt -> bindParam( ':LOGIN', $_POST['loginName'] );
17
 
                $oldPassword = md5( $_POST['password'] );
18
 
                $stmt -> bindParam( ':PASSW', $oldPassword );
19
 
                $stmt -> execute();
20
 
 
21
 
                if( $stmt -> rowCount() == 1 ) { //Old password correct
22
 
                        $student = $stmt -> fetch( PDO::FETCH_ASSOC );
23
 
                        //Update password to new password
24
 
                        $updateString = "UPDATE Student 
25
 
                                SET Student.passw=:NEWPASSW
26
 
                                WHERE Student.ssn=:SSN
27
 
                                AND Student.loginName=:LOGIN;";
28
 
                        $updateStmt = $pdo -> prepare( $updateString );
29
 
                        $newPassword = md5( $_POST['newPassword'] );
30
 
                        $updateStmt -> bindParam(':NEWPASSW', $newPassword );
31
 
                        $updateStmt -> bindParam(':LOGIN', $_POST['loginName'] );
32
 
                        $updateStmt -> bindParam(':SSN', $student['ssn'] );
33
 
                        $updateStmt -> execute();
34
 
                        if( $updateStmt -> execute()) {
35
 
                                $errorMsg = "New password stored";
36
 
                        } else {
37
 
                                $errorMsg = "ERROR: Failed to change password";
38
 
                        }
39
 
                }
40
 
        }
41
 
        
42
 
        include $content;
43
 
?>
 
 
b'\\ No newline at end of file'