These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | require_once (__DIR__ . '/vendor/autoload.php'); |
||
4 | require_once (__DIR__ . '/config/database.php'); |
||
5 | use ChatApp\User; |
||
6 | use ChatApp\Profile; |
||
7 | use ChatApp\Session; |
||
8 | |||
9 | $user = explode("/", $_SERVER['REQUEST_URI']); |
||
10 | $user = $user[count($user)-1]; |
||
11 | $session = new Session(); |
||
12 | $userId = $session->get('start'); |
||
13 | if($userId != null and $user == "account.php") |
||
0 ignored issues
–
show
|
|||
14 | { |
||
15 | $obUser = new User(); |
||
16 | $row = $obUser->UserDetails($userId, True); |
||
17 | |||
18 | if($row != NULL) |
||
19 | { |
||
20 | $location = URL . "/account.php/". $row['username']; |
||
21 | header("Location:".$location); |
||
22 | } |
||
23 | } |
||
24 | elseif ($user != "account.php") |
||
25 | { |
||
26 | $obUser = new User(); |
||
27 | $row = $obUser->UserDetails($user, False); |
||
28 | if($row != NULL): |
||
29 | $userId = $row['login_id']; |
||
30 | $details = Profile::getProfile($userId); |
||
31 | if($details != NULL) |
||
32 | $row = array_merge($row, $details); |
||
33 | else |
||
34 | header("Location:".URL."/error.php"); |
||
35 | ?> |
||
36 | |||
37 | <!Doctype html> |
||
38 | <html> |
||
39 | <head> |
||
40 | <title>OpenChat || Profile</title> |
||
41 | <link rel="stylesheet" href="../css/profile.css"> |
||
42 | </head> |
||
43 | <body> |
||
44 | |||
45 | <div class="header"> |
||
46 | <a id="brand" href="">OpenChat</a> |
||
47 | <ul class="nav-right"> |
||
48 | <li><a href="../index.php">About</a></li> |
||
49 | <?php if($session->get('start') != null): ?> |
||
50 | <li><a href="../message.php">Message</a></li> |
||
51 | <li><a href="../logout.php">Log out</a></li> |
||
52 | <?php else: ?> |
||
53 | <li><a href="../login.php">Login</a></li> |
||
54 | <li><a href="../register.php">Register</a></li> |
||
55 | <?php endif; ?> |
||
56 | </ul> |
||
57 | </div> |
||
58 | |||
59 | <div class="main"> |
||
60 | <div class="boxx" > |
||
61 | |||
62 | <div class="pic"> |
||
63 | <img src="../assests/ankit.png"> |
||
64 | </div> |
||
65 | |||
66 | <div class="brief"> |
||
67 | <h1 id="name">Name: <?php echo $row['name']; ?></h1><br> |
||
68 | <?php foreach ($row as $key => $value) { |
||
69 | if($key =='username' and $value != null) |
||
70 | echo '<p>Username: '.$row["username"] .'</p><br>'; |
||
71 | if($key == 'email' and $value != null) |
||
72 | echo '<p>Email Id: '.$row["email"] .'</p><br>'; |
||
73 | if($key == 'status' and $value != null) |
||
74 | echo '<p>Status: '.$row["status"] .'</p><br>'; |
||
75 | if($key == 'education' and $value != null) |
||
76 | echo '<p>Education: '.$row["education"] .'</p><br>'; |
||
77 | if($key == 'gender' and $value != null) |
||
78 | echo '<p>Gender: '.$row["gender"] .'</p><br>'; |
||
79 | } |
||
80 | ?> |
||
81 | </div> |
||
82 | <?php if($session->get('start') == $row['login_id']): ?> |
||
83 | <div class="edit"> |
||
84 | <a href="#">Edit Profile</a> |
||
85 | </div> |
||
86 | <?php endif; ?> |
||
87 | </div> |
||
88 | |||
89 | <?php |
||
90 | if($session->get('start') == $row['login_id']): |
||
91 | ?> |
||
92 | |||
93 | <div class="boxx" id="profile"> |
||
94 | <form method="post" action="../profile_generate.php"> |
||
95 | <label>Status : </label> |
||
96 | <textarea name="status" id="status"><?php echo $row['status']; ?></textarea> |
||
97 | <label>Education : </label> |
||
98 | <input type="text" name="education" id="education" value="<?php echo $row['education']; ?>"></input> |
||
99 | <label>Gender : </label><br> |
||
100 | <input type="radio" name="gender" id="gender" value="Male" <?php echo ($row['gender']=='Male')?'checked':'' ?>> Male<br> |
||
101 | <input type="radio" name="gender" id="gender" value="Female" <?php echo ($row['gender']=='Female')?'checked':'' ?>> Female<br> |
||
102 | <input type="submit" name="submit" value="Done" id="submit"> |
||
103 | </form> |
||
104 | </div> |
||
105 | <?php |
||
106 | endif; |
||
107 | ?> |
||
108 | </div> |
||
109 | |||
110 | <div class="footer"> |
||
111 | <h3 class="footer_text">Made with love by <a href="#">Ankit Jain</a></h3> |
||
112 | </div> |
||
113 | |||
114 | <script type="text/javascript" src="../js/jquery-3.0.0.min.js"></script> |
||
115 | <script type="text/javascript" src="../js/profile.js"></script> |
||
116 | <script type="text/javascript" src="../node_modules/place-holder.js/place-holder.min.js"></script> |
||
117 | </body> |
||
118 | </html> |
||
119 | <?php |
||
120 | else: |
||
121 | header("Location:".URL."/error.php"); |
||
122 | endif; |
||
123 | } |
||
124 | else |
||
125 | { |
||
126 | header("Location: ".URL); |
||
127 | } |
||
128 | ?> |
||
129 | |||
130 |
PHP has two types of connecting operators (logical operators, and boolean operators):
and
&&
or
||
The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like
&&
, or||
.Let’s take a look at a few examples:
Logical Operators are used for Control-Flow
One case where you explicitly want to use logical operators is for control-flow such as this:
Since
die
introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined withthrow
at this point:These limitations lead to logical operators rarely being of use in current PHP code.