Test Setup Failed
Push — master ( f3ea8f...027aaa )
by Ankit
02:16
created

account.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<!Doctype html>
2
<html>
3
	
4
5
<?php
6
session_start();
7
include 'database.php';
8
$connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
9
$user=substr($_SERVER['REQUEST_URI'],22);
10
// var_dump($user);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
11
if(isset($_SESSION['start']) and !$user)
12
{
13
	$login_id=$_SESSION['start'];
14
	$query="SELECT username from login where login_id='$login_id'";
15
	if($result=$connect->query($query))
16
	{
17
		if($result->num_rows >0)
18
		{
19
			$row=$result->fetch_assoc();
20
			$location="http://localhost/openchat/account.php/".$row['username'];
21
			header("Location:".$location);
22
		}
23
	}
24
25
}
26
27
else if($user)
28
{
29
	$query="SELECT * from login where username='$user'";
30
	if($result=$connect->query($query))
31
	{
32
		if($result->num_rows >0)
33
		{
34
			$row=$result->fetch_assoc();
35
			$id=$row['login_id'];
36
			$query="SELECT * from profile where login_id='$id'";
37
			if($result=$connect->query($query))
38
			{
39
				if($result->num_rows>0)
40
				{
41
					$r=$result->fetch_assoc();
42
					$row=array_merge($row,$r);
43
					// var_dump($row);
44
				}
45
			}
46
			else
47
			{
48
				die("error");
49
			}
50
?>
51
	<head>
52
		<title>OpenChat || Profile</title>
53
        <link rel="stylesheet" href="../css/profile.css">
54
	</head>
55
56
57
58
	<body>
59
60
		<div class="header">
61
            <a id="brand" href="">OpenChat</a>
62
            <ul class="nav-right">
63
                <li><a href="../index.php">About</a></li>
64
                <?php if(isset($_SESSION['start']))
65
				{
66
				?>
67
				<li><a href="../message.php">Message</a></li>
68
				<li><a href="../registration-module/source/class.logout.php">Log out</a></li>
69
				<?php 
70
				}
71
				else
72
				{
73
				?>
74
				<li><a href="../login.php">Login</a></li>
75
				<li><a href="../register.php">Register</a></li>
76
				<?php
77
				}
78
				?>
79
            </ul>
80
        </div>
81
			
82
83
84
		
85
        <div class="main">
86
			<div class="boxx" >
87
88
				<div class="pic">
89
					<img src="../ankit.png">
90
				</div>
91
92
				<div class="brief">
93
					<h1 id="name">Name: <?php echo $row['name']; ?></h1><br>
94
					<?php foreach ($row as $key => $value) {
95
						if($key=='username' and $value!=null)
96
							echo '<p>Username: '.$row["username"] .'</p><br>';
97
						if($key=='email' and $value!=null)
98
							echo '<p>Email Id: '.$row["email"] .'</p><br>';
99
						if($key=='status' and $value!=null)
100
							echo '<p>Status: '.$row["status"] .'</p><br>';
101
						if($key=='education' and $value!=null)
102
							echo '<p>Education: '.$row["education"] .'</p><br>';
103
						if($key=='gender' and $value!=null)
104
							echo '<p>Gender: 	'.$row["gender"] .'</p><br>';
105
					}
106
					?>
107
				</div>	
108
				<?php if($_SESSION['start']==$row['login_id'])
109
				{
110
					?>
111
				<div class="edit"><a href="#">Edit Profile</a></div>
112
				<?php
113
				}
114
				?>	
115
			</div>	
116
	
117
			<?php 
118
			if($_SESSION['start']==$row['login_id'])
119
			{
120
				?>
121
		
122
			<div class="boxx" id="profile">
123
				<form method="post" action="../profile_generate.php">
124
					<label>Status : </label>
125
					<textarea name="status" id="status"><?php echo $row['status']; ?></textarea>
126
					<label>Education : </label>
127
					<input type="text" name="education" id="education" value="<?php echo $row['education']; ?>"></input>
128
					<label>Gender : </label><br>
129
					<input type="radio" name="gender" id="gender" value="Male" <?php echo ($row['gender']=='Male')?'checked':'' ?>> Male<br>
130
					<input type="radio" name="gender" id="gender" value="Female" <?php echo ($row['gender']=='Female')?'checked':'' ?>> Female<br>
131
					<input type="submit" name="submit" value="Done" id="submit">
132
				</form>
133
			</div>
134
			<?php
135
			}
136
			?>
137
		</div>
138
139
140
		<div class="footer">
141
			<h3 class="footer_text">Made with love by <a href="#">Ankit Jain</a></h3>
142
		</div>
143
	
144
	</body>
145
    <script type="text/javascript" src="../js/jquery-3.0.0.min.js"></script>
146
	<script type="text/javascript" src="../js/profile.js"></script>
147
    <script type="text/javascript" src="../placeholder.js/placeholder.js"></script>
148
149
150
</html>
151
152
153
154
<?php
155
		}
156
		else
157
		{
158
			die("Invalid User");
159
		}
160
	}
161
	else
162
	{
163
		die("invalid");
164
	}
165
}
166
else
167
{
168
	header("Location:http://localhost/openchat/index.php");
169
}
170
?>
171
172