@@ -1,33 +1,33 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | session_start(); |
| 3 | -require_once (__DIR__ . '/config/database.php'); |
|
| 3 | +require_once (__DIR__.'/config/database.php'); |
|
| 4 | 4 | $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
| 5 | -$login_id=$_SESSION['start']; |
|
| 6 | -if(isset($_POST['submit'])) |
|
| 5 | +$login_id = $_SESSION['start']; |
|
| 6 | +if (isset($_POST['submit'])) |
|
| 7 | 7 | { |
| 8 | - $query="SELECT * from profile where login_id='$login_id'"; |
|
| 9 | - if($result=$connect->query($query)) |
|
| 8 | + $query = "SELECT * from profile where login_id='$login_id'"; |
|
| 9 | + if ($result = $connect->query($query)) |
|
| 10 | 10 | { |
| 11 | - if($result->num_rows>0) |
|
| 11 | + if ($result->num_rows > 0) |
|
| 12 | 12 | { |
| 13 | - $row=$result->fetch_assoc(); |
|
| 13 | + $row = $result->fetch_assoc(); |
|
| 14 | 14 | } |
| 15 | 15 | } |
| 16 | - if(trim($_POST['status'])) |
|
| 17 | - $status=$_POST['status']; |
|
| 16 | + if (trim($_POST['status'])) |
|
| 17 | + $status = $_POST['status']; |
|
| 18 | 18 | else |
| 19 | - $status=$row['status']; |
|
| 20 | - if(trim($_POST['education'])) |
|
| 21 | - $edu=$_POST['education']; |
|
| 19 | + $status = $row['status']; |
|
| 20 | + if (trim($_POST['education'])) |
|
| 21 | + $edu = $_POST['education']; |
|
| 22 | 22 | else |
| 23 | - $edu=$row['education']; |
|
| 24 | - if(isset($_POST['gender'])) |
|
| 25 | - $gender=$_POST['gender']; |
|
| 23 | + $edu = $row['education']; |
|
| 24 | + if (isset($_POST['gender'])) |
|
| 25 | + $gender = $_POST['gender']; |
|
| 26 | 26 | else |
| 27 | - $gender=$row['gender']; |
|
| 27 | + $gender = $row['gender']; |
|
| 28 | 28 | |
| 29 | - $query="UPDATE profile set status='$status', education='$edu', gender='$gender' where login_id='$login_id'"; |
|
| 30 | - if($result=$connect->query($query)) |
|
| 29 | + $query = "UPDATE profile set status='$status', education='$edu', gender='$gender' where login_id='$login_id'"; |
|
| 30 | + if ($result = $connect->query($query)) |
|
| 31 | 31 | { |
| 32 | 32 | header('Location: account.php'); |
| 33 | 33 | } |
@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once (__DIR__ . '/vendor/autoload.php'); |
|
| 4 | -require_once (__DIR__ . '/config/database.php'); |
|
| 3 | +require_once (__DIR__.'/vendor/autoload.php'); |
|
| 4 | +require_once (__DIR__.'/config/database.php'); |
|
| 5 | 5 | use ChatApp\User; |
| 6 | 6 | use ChatApp\Profile; |
| 7 | 7 | use ChatApp\Session; |
| 8 | 8 | |
| 9 | 9 | $user = explode("/", $_SERVER['REQUEST_URI']); |
| 10 | -$user = $user[count($user)-1]; |
|
| 10 | +$user = $user[count($user) - 1]; |
|
| 11 | 11 | $userId = Session::get('start'); |
| 12 | -if($userId != null && $user == "account.php") |
|
| 12 | +if ($userId != null && $user == "account.php") |
|
| 13 | 13 | { |
| 14 | 14 | $obUser = new User(); |
| 15 | 15 | $row = $obUser->UserDetails($userId, True); |
| 16 | 16 | |
| 17 | - if($row != NULL) |
|
| 17 | + if ($row != NULL) |
|
| 18 | 18 | { |
| 19 | - $location = URL . "/account.php/". $row['username']; |
|
| 19 | + $location = URL."/account.php/".$row['username']; |
|
| 20 | 20 | header("Location:".$location); |
| 21 | 21 | } |
| 22 | 22 | } |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | { |
| 25 | 25 | $obUser = new User(); |
| 26 | 26 | $row = $obUser->UserDetails($user, False); |
| 27 | - if($row != NULL): |
|
| 27 | + if ($row != NULL): |
|
| 28 | 28 | $userId = $row['login_id']; |
| 29 | 29 | $details = Profile::getProfile($userId); |
| 30 | - if($details != NULL) |
|
| 30 | + if ($details != NULL) |
|
| 31 | 31 | $row = array_merge($row, $details); |
| 32 | 32 | else |
| 33 | 33 | header("Location:".URL."/error.php"); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | <a id="brand" href="">OpenChat</a> |
| 46 | 46 | <ul class="nav-right"> |
| 47 | 47 | <li><a href="../index.php">About</a></li> |
| 48 | - <?php if(Session::get('start') != null): ?> |
|
| 48 | + <?php if (Session::get('start') != null): ?> |
|
| 49 | 49 | <li><a href="../message.php">Message</a></li> |
| 50 | 50 | <li><a href="../logout.php">Log out</a></li> |
| 51 | 51 | <?php else: ?> |
@@ -65,20 +65,20 @@ discard block |
||
| 65 | 65 | <div class="brief"> |
| 66 | 66 | <h1 id="name">Name: <?php echo $row['name']; ?></h1><br> |
| 67 | 67 | <?php foreach ($row as $key => $value) { |
| 68 | - if($key =='username' && $value != null) |
|
| 69 | - echo '<p>Username: '.$row["username"] .'</p><br>'; |
|
| 70 | - if($key == 'email' && $value != null) |
|
| 71 | - echo '<p>Email Id: '.$row["email"] .'</p><br>'; |
|
| 72 | - if($key == 'status' && $value != null) |
|
| 73 | - echo '<p>Status: '.$row["status"] .'</p><br>'; |
|
| 74 | - if($key == 'education' && $value != null) |
|
| 75 | - echo '<p>Education: '.$row["education"] .'</p><br>'; |
|
| 76 | - if($key == 'gender' && $value != null) |
|
| 77 | - echo '<p>Gender: '.$row["gender"] .'</p><br>'; |
|
| 68 | + if ($key == 'username' && $value != null) |
|
| 69 | + echo '<p>Username: '.$row["username"].'</p><br>'; |
|
| 70 | + if ($key == 'email' && $value != null) |
|
| 71 | + echo '<p>Email Id: '.$row["email"].'</p><br>'; |
|
| 72 | + if ($key == 'status' && $value != null) |
|
| 73 | + echo '<p>Status: '.$row["status"].'</p><br>'; |
|
| 74 | + if ($key == 'education' && $value != null) |
|
| 75 | + echo '<p>Education: '.$row["education"].'</p><br>'; |
|
| 76 | + if ($key == 'gender' && $value != null) |
|
| 77 | + echo '<p>Gender: '.$row["gender"].'</p><br>'; |
|
| 78 | 78 | } |
| 79 | 79 | ?> |
| 80 | 80 | </div> |
| 81 | - <?php if(Session::get('start') == $row['login_id']): ?> |
|
| 81 | + <?php if (Session::get('start') == $row['login_id']): ?> |
|
| 82 | 82 | <div class="edit"> |
| 83 | 83 | <a href="#">Edit Profile</a> |
| 84 | 84 | </div> |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | </div> |
| 87 | 87 | |
| 88 | 88 | <?php |
| 89 | - if(Session::get('start') == $row['login_id']): |
|
| 89 | + if (Session::get('start') == $row['login_id']): |
|
| 90 | 90 | ?> |
| 91 | 91 | |
| 92 | 92 | <div class="boxx" id="profile"> |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | <label>Education : </label> |
| 97 | 97 | <input type="text" name="education" id="education" value="<?php echo $row['education']; ?>"></input> |
| 98 | 98 | <label>Gender : </label><br> |
| 99 | - <input type="radio" name="gender" id="gender" value="Male" <?php echo ($row['gender']=='Male')?'checked':'' ?>> Male<br> |
|
| 100 | - <input type="radio" name="gender" id="gender" value="Female" <?php echo ($row['gender']=='Female')?'checked':'' ?>> Female<br> |
|
| 99 | + <input type="radio" name="gender" id="gender" value="Male" <?php echo ($row['gender'] == 'Male') ? 'checked' : '' ?>> Male<br> |
|
| 100 | + <input type="radio" name="gender" id="gender" value="Female" <?php echo ($row['gender'] == 'Female') ? 'checked' : '' ?>> Female<br> |
|
| 101 | 101 | <input type="submit" name="submit" value="Done" id="submit"> |
| 102 | 102 | </form> |
| 103 | 103 | </div> |
@@ -19,19 +19,19 @@ discard block |
||
| 19 | 19 | $location = URL . "/account.php/". $row['username']; |
| 20 | 20 | header("Location:".$location); |
| 21 | 21 | } |
| 22 | -} |
|
| 23 | -elseif ($user != "account.php") |
|
| 22 | +} elseif ($user != "account.php") |
|
| 24 | 23 | { |
| 25 | 24 | $obUser = new User(); |
| 26 | 25 | $row = $obUser->UserDetails($user, False); |
| 27 | 26 | if($row != NULL): |
| 28 | 27 | $userId = $row['login_id']; |
| 29 | 28 | $details = Profile::getProfile($userId); |
| 30 | - if($details != NULL) |
|
| 31 | - $row = array_merge($row, $details); |
|
| 32 | - else |
|
| 33 | - header("Location:".URL."/error.php"); |
|
| 34 | -?> |
|
| 29 | + if($details != NULL) { |
|
| 30 | + $row = array_merge($row, $details); |
|
| 31 | + } else { |
|
| 32 | + header("Location:".URL."/error.php"); |
|
| 33 | + } |
|
| 34 | + ?> |
|
| 35 | 35 | |
| 36 | 36 | <!Doctype html> |
| 37 | 37 | <html> |
@@ -48,10 +48,13 @@ discard block |
||
| 48 | 48 | <?php if(Session::get('start') != null): ?> |
| 49 | 49 | <li><a href="../message.php">Message</a></li> |
| 50 | 50 | <li><a href="../logout.php">Log out</a></li> |
| 51 | - <?php else: ?> |
|
| 51 | + <?php else { |
|
| 52 | + : ?> |
|
| 52 | 53 | <li><a href="../login.php">Login</a></li> |
| 53 | 54 | <li><a href="../register.php">Register</a></li> |
| 54 | - <?php endif; ?> |
|
| 55 | + <?php endif; |
|
| 56 | +} |
|
| 57 | +?> |
|
| 55 | 58 | </ul> |
| 56 | 59 | </div> |
| 57 | 60 | |
@@ -65,16 +68,21 @@ discard block |
||
| 65 | 68 | <div class="brief"> |
| 66 | 69 | <h1 id="name">Name: <?php echo $row['name']; ?></h1><br> |
| 67 | 70 | <?php foreach ($row as $key => $value) { |
| 68 | - if($key =='username' && $value != null) |
|
| 69 | - echo '<p>Username: '.$row["username"] .'</p><br>'; |
|
| 70 | - if($key == 'email' && $value != null) |
|
| 71 | - echo '<p>Email Id: '.$row["email"] .'</p><br>'; |
|
| 72 | - if($key == 'status' && $value != null) |
|
| 73 | - echo '<p>Status: '.$row["status"] .'</p><br>'; |
|
| 74 | - if($key == 'education' && $value != null) |
|
| 75 | - echo '<p>Education: '.$row["education"] .'</p><br>'; |
|
| 76 | - if($key == 'gender' && $value != null) |
|
| 77 | - echo '<p>Gender: '.$row["gender"] .'</p><br>'; |
|
| 71 | + if($key =='username' && $value != null) { |
|
| 72 | + echo '<p>Username: '.$row["username"] .'</p><br>'; |
|
| 73 | + } |
|
| 74 | + if($key == 'email' && $value != null) { |
|
| 75 | + echo '<p>Email Id: '.$row["email"] .'</p><br>'; |
|
| 76 | + } |
|
| 77 | + if($key == 'status' && $value != null) { |
|
| 78 | + echo '<p>Status: '.$row["status"] .'</p><br>'; |
|
| 79 | + } |
|
| 80 | + if($key == 'education' && $value != null) { |
|
| 81 | + echo '<p>Education: '.$row["education"] .'</p><br>'; |
|
| 82 | + } |
|
| 83 | + if($key == 'gender' && $value != null) { |
|
| 84 | + echo '<p>Gender: '.$row["gender"] .'</p><br>'; |
|
| 85 | + } |
|
| 78 | 86 | } |
| 79 | 87 | ?> |
| 80 | 88 | </div> |
@@ -116,11 +124,12 @@ discard block |
||
| 116 | 124 | </body> |
| 117 | 125 | </html> |
| 118 | 126 | <?php |
| 119 | - else: |
|
| 127 | + else { |
|
| 128 | + : |
|
| 120 | 129 | header("Location:".URL."/error.php"); |
| 130 | + } |
|
| 121 | 131 | endif; |
| 122 | -} |
|
| 123 | -else |
|
| 132 | +} else |
|
| 124 | 133 | { |
| 125 | 134 | header("Location: ".URL); |
| 126 | 135 | } |