@@ -6,41 +6,41 @@ discard block |
||
| 6 | 6 | session_start(); |
| 7 | 7 | include 'database.php'; |
| 8 | 8 | $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
| 9 | -$user=explode("/", $_SERVER['REQUEST_URI']); |
|
| 10 | -$user = $user[count($user)-1]; |
|
| 9 | +$user = explode("/", $_SERVER['REQUEST_URI']); |
|
| 10 | +$user = $user[count($user) - 1]; |
|
| 11 | 11 | var_dump($user); |
| 12 | -if(isset($_SESSION['start']) and !$user) |
|
| 12 | +if (isset($_SESSION['start']) and !$user) |
|
| 13 | 13 | { |
| 14 | - $login_id=$_SESSION['start']; |
|
| 15 | - $query="SELECT username from login where login_id='$login_id'"; |
|
| 16 | - if($result=$connect->query($query)) |
|
| 14 | + $login_id = $_SESSION['start']; |
|
| 15 | + $query = "SELECT username from login where login_id='$login_id'"; |
|
| 16 | + if ($result = $connect->query($query)) |
|
| 17 | 17 | { |
| 18 | - if($result->num_rows >0) |
|
| 18 | + if ($result->num_rows > 0) |
|
| 19 | 19 | { |
| 20 | - $row=$result->fetch_assoc(); |
|
| 21 | - $location="http://localhost/openchat/account.php/".$row['username']; |
|
| 20 | + $row = $result->fetch_assoc(); |
|
| 21 | + $location = "http://localhost/openchat/account.php/".$row['username']; |
|
| 22 | 22 | header("Location:".$location); |
| 23 | 23 | } |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | -else if($user) |
|
| 28 | +else if ($user) |
|
| 29 | 29 | { |
| 30 | - $query="SELECT * from login where username='$user'"; |
|
| 31 | - if($result=$connect->query($query)) |
|
| 30 | + $query = "SELECT * from login where username='$user'"; |
|
| 31 | + if ($result = $connect->query($query)) |
|
| 32 | 32 | { |
| 33 | - if($result->num_rows >0) |
|
| 33 | + if ($result->num_rows > 0) |
|
| 34 | 34 | { |
| 35 | - $row=$result->fetch_assoc(); |
|
| 36 | - $id=$row['login_id']; |
|
| 37 | - $query="SELECT * from profile where login_id='$id'"; |
|
| 38 | - if($result=$connect->query($query)) |
|
| 35 | + $row = $result->fetch_assoc(); |
|
| 36 | + $id = $row['login_id']; |
|
| 37 | + $query = "SELECT * from profile where login_id='$id'"; |
|
| 38 | + if ($result = $connect->query($query)) |
|
| 39 | 39 | { |
| 40 | - if($result->num_rows>0) |
|
| 40 | + if ($result->num_rows > 0) |
|
| 41 | 41 | { |
| 42 | - $r=$result->fetch_assoc(); |
|
| 43 | - $row=array_merge($row,$r); |
|
| 42 | + $r = $result->fetch_assoc(); |
|
| 43 | + $row = array_merge($row, $r); |
|
| 44 | 44 | // var_dump($row); |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | <a id="brand" href="">OpenChat</a> |
| 63 | 63 | <ul class="nav-right"> |
| 64 | 64 | <li><a href="../index.php">About</a></li> |
| 65 | - <?php if(isset($_SESSION['start'])) |
|
| 65 | + <?php if (isset($_SESSION['start'])) |
|
| 66 | 66 | { |
| 67 | 67 | ?> |
| 68 | 68 | <li><a href="../message.php">Message</a></li> |
@@ -93,20 +93,20 @@ discard block |
||
| 93 | 93 | <div class="brief"> |
| 94 | 94 | <h1 id="name">Name: <?php echo $row['name']; ?></h1><br> |
| 95 | 95 | <?php foreach ($row as $key => $value) { |
| 96 | - if($key=='username' and $value!=null) |
|
| 97 | - echo '<p>Username: '.$row["username"] .'</p><br>'; |
|
| 98 | - if($key=='email' and $value!=null) |
|
| 99 | - echo '<p>Email Id: '.$row["email"] .'</p><br>'; |
|
| 100 | - if($key=='status' and $value!=null) |
|
| 101 | - echo '<p>Status: '.$row["status"] .'</p><br>'; |
|
| 102 | - if($key=='education' and $value!=null) |
|
| 103 | - echo '<p>Education: '.$row["education"] .'</p><br>'; |
|
| 104 | - if($key=='gender' and $value!=null) |
|
| 105 | - echo '<p>Gender: '.$row["gender"] .'</p><br>'; |
|
| 96 | + if ($key == 'username' and $value != null) |
|
| 97 | + echo '<p>Username: '.$row["username"].'</p><br>'; |
|
| 98 | + if ($key == 'email' and $value != null) |
|
| 99 | + echo '<p>Email Id: '.$row["email"].'</p><br>'; |
|
| 100 | + if ($key == 'status' and $value != null) |
|
| 101 | + echo '<p>Status: '.$row["status"].'</p><br>'; |
|
| 102 | + if ($key == 'education' and $value != null) |
|
| 103 | + echo '<p>Education: '.$row["education"].'</p><br>'; |
|
| 104 | + if ($key == 'gender' and $value != null) |
|
| 105 | + echo '<p>Gender: '.$row["gender"].'</p><br>'; |
|
| 106 | 106 | } |
| 107 | 107 | ?> |
| 108 | 108 | </div> |
| 109 | - <?php if($_SESSION['start']==$row['login_id']) |
|
| 109 | + <?php if ($_SESSION['start'] == $row['login_id']) |
|
| 110 | 110 | { |
| 111 | 111 | ?> |
| 112 | 112 | <div class="edit"><a href="#">Edit Profile</a></div> |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | </div> |
| 117 | 117 | |
| 118 | 118 | <?php |
| 119 | - if($_SESSION['start']==$row['login_id']) |
|
| 119 | + if ($_SESSION['start'] == $row['login_id']) |
|
| 120 | 120 | { |
| 121 | 121 | ?> |
| 122 | 122 | |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | <label>Education : </label> |
| 128 | 128 | <input type="text" name="education" id="education" value="<?php echo $row['education']; ?>"></input> |
| 129 | 129 | <label>Gender : </label><br> |
| 130 | - <input type="radio" name="gender" id="gender" value="Male" <?php echo ($row['gender']=='Male')?'checked':'' ?>> Male<br> |
|
| 131 | - <input type="radio" name="gender" id="gender" value="Female" <?php echo ($row['gender']=='Female')?'checked':'' ?>> Female<br> |
|
| 130 | + <input type="radio" name="gender" id="gender" value="Male" <?php echo ($row['gender'] == 'Male') ? 'checked' : '' ?>> Male<br> |
|
| 131 | + <input type="radio" name="gender" id="gender" value="Female" <?php echo ($row['gender'] == 'Female') ? 'checked' : '' ?>> Female<br> |
|
| 132 | 132 | <input type="submit" name="submit" value="Done" id="submit"> |
| 133 | 133 | </form> |
| 134 | 134 | </div> |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | // Define database connection constants |
| 3 | 3 | define('DB_HOST', 'localhost'); |
| 4 | 4 | define('DB_USER', 'root'); |
| 5 | - define('DB_PASSWORD',''); |
|
| 5 | + define('DB_PASSWORD', ''); |
|
| 6 | 6 | define('DB_NAME', 'openchat'); |
| 7 | 7 | define('URL', URL()); |
| 8 | 8 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | $host = $_SERVER['SERVER_NAME']; |
| 13 | 13 | $port = $_SERVER['SERVER_PORT']; |
| 14 | 14 | $fol = ""; |
| 15 | - if(@$_SERVER['SERVER_ADDR']!=NULL) |
|
| 15 | + if (@$_SERVER['SERVER_ADDR'] != NULL) |
|
| 16 | 16 | { |
| 17 | 17 | $fol = explode('/', $_SERVER['PHP_SELF'])[1]; |
| 18 | 18 | } |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | // Define database connection constants |
| 3 | 3 | define('DB_HOST', 'localhost'); |
| 4 | 4 | define('DB_USER', 'root'); |
| 5 | - define('DB_PASSWORD',''); |
|
| 5 | + define('DB_PASSWORD', ''); |
|
| 6 | 6 | define('DB_NAME', 'openchat'); |
| 7 | 7 | define('URL', URL()); |
| 8 | 8 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | $host = $_SERVER['SERVER_NAME']; |
| 13 | 13 | $port = $_SERVER['SERVER_PORT']; |
| 14 | 14 | $fol = ""; |
| 15 | - if(@$_SERVER['SERVER_ADDR']!=NULL) |
|
| 15 | + if (@$_SERVER['SERVER_ADDR'] != NULL) |
|
| 16 | 16 | { |
| 17 | 17 | $fol = "/".explode('/', $_SERVER['PHP_SELF'])[1]; |
| 18 | 18 | } |