user id in link
Ik ben al weken bezig om een user id in een link te krijgen.
Van alles geprobeerd, maar tot nu toe alleen dit resultaat: profile.php?id=Sem
de bedoeling is dus het zo moet zijn profile.php?id=1
Dit is de script waar ik tot nu toe nog steeds mee aaan het vechten ben:
Code (php)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
<?php
if(isset($_SESSION['username']))
{
$req = mysql_query('select id, username, email from users');
while($dnn = mysql_fetch_array($req))
?>
<a href="profile.php?id=<?php echo $_SESSION['username']; ?>">My Profile</a>
if(isset($_SESSION['username']))
{
$req = mysql_query('select id, username, email from users');
while($dnn = mysql_fetch_array($req))
?>
<a href="profile.php?id=<?php echo $_SESSION['username']; ?>">My Profile</a>
Ook heb ik deze combinatie's geprobeerd:
Iemand die mij hiermee kan helpen?
Mvg,
Sem.
Gelieve in het vervolg bij code de [code][/code]-tags gebruiken.
Hier kan je meer lezen over de mogelijke opmaakcodes.
Alvast bedankt![/modedit]
Gewijzigd op 04/04/2016 13:49:09 door Sem Cool
Je gebruikt proactief: $_SESSION['username']
Ergens maak je deze aan ( waarschijnlijk bij het inloggen ).
Hierin "set" je de gebruikersnaam en niet het ID.
Je geeft ook aan dat je: $_SESSION['id'] geprobeerd hebt, maar deze bestaat waarschijnlijk niet, omdat deze niet aangemaakt wordt bij het inloggen.
Mijn advies: zoek even in de code bij je inlogscript.
Edit:
Code (php)
1
2
3
4
5
6
2
3
4
5
6
<?php
// je gebruikt deze code
while($dnn = mysql_fetch_array($req))
// en roept hem zo op:
echo $_dnn['id'];
?>
// je gebruikt deze code
while($dnn = mysql_fetch_array($req))
// en roept hem zo op:
echo $_dnn['id'];
?>
$_dnn & $dnn zijn 2 verschillende variabelen.
Gewijzigd op 04/04/2016 13:13:23 door E vH
Onderstaande code geeft een lijst met alle gebruikers en een link naar de profiel pagina met behulp van:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
<?php
echo '<ul>';
$query = mysql_query('SELECT id, username FROM users');
while ($row = mysql_fetch_row($query)) {
echo '<li><a href="profile.php?id='.$row['id'].'">'.$row['username'].'</a></li>';
}
echo '</ul>';
?>
echo '<ul>';
$query = mysql_query('SELECT id, username FROM users');
while ($row = mysql_fetch_row($query)) {
echo '<li><a href="profile.php?id='.$row['id'].'">'.$row['username'].'</a></li>';
}
echo '</ul>';
?>
Op de profiel pagina doe je dan:
Code (php)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
<?php
if (isset($_GET['id'])) {
$query = mysql_query('SELECT id, username, email FROM users WHERE id = "'.mysql_real_escape_string($_GET['id']).'"');
// Verdere afhandeling
} else {
echo 'Geen ID parameter...';
}
?>
if (isset($_GET['id'])) {
$query = mysql_query('SELECT id, username, email FROM users WHERE id = "'.mysql_real_escape_string($_GET['id']).'"');
// Verdere afhandeling
} else {
echo 'Geen ID parameter...';
}
?>
Gewijzigd op 04/04/2016 13:15:27 door Joakim Broden
Bedankt voor snelle reactie, ik ga gelijk even snuffelen in de loginscript.
PS maak je ook onderscheid tussen:
- een weergavepagina van profielen (in dit geval heb je een user id (of wellicht naam - beter voor SEO?) nodig)
- een wijzigpagina voor je eigen profiel (in dit geval heb je geen user id nodig, zoals eerder uitgelegd)
- een wijzigpagina voor een admin (die mogelijk profielen van andere mensen kan wijzigen, in dat geval is weer wel een user id nodig om te bepalen welk profiel je bedoelt)
PPS gebruik MySQLi of PDO, maar geen mysql_-functies meer.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
//We check if the form has been sent
if(isset($_POST['username'], $_POST['password'], $_POST['passverif'], $_POST['email'], $_POST['avatar']) and $_POST['username']!='')
{
//We remove slashes depending on the configuration
if(get_magic_quotes_gpc())
{
$_POST['username'] = stripslashes($_POST['username']);
$_POST['password'] = stripslashes($_POST['password']);
$_POST['passverif'] = stripslashes($_POST['passverif']);
$_POST['email'] = stripslashes($_POST['email']);
$_POST['avatar'] = stripslashes($_POST['avatar']);
}
//We check if the two passwords are identical
if($_POST['password']==$_POST['passverif'])
{
//We check if the password has 6 or more characters
if(strlen($_POST['password'])>=6)
{
//We check if the email form is valid
if(preg_match('#^(([a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+\.?)*[a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+)@(([a-z0-9-_]+\.?)*[a-z0-9-_]+)\.[a-z]{2,}$#i',$_POST['email']))
{
//We protect the variables
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$email = mysql_real_escape_string($_POST['email']);
$avatar = mysql_real_escape_string($_POST['avatar']);
//We check if there is no other user using the same username
$dn = mysql_num_rows(mysql_query('select id from users where username="'.$username.'"'));
if($dn==0)
{
//We count the number of users to give an ID to this one
$dn2 = mysql_num_rows(mysql_query('select id from users'));
$id = $dn2+1;
//We save the informations to the databse
if(mysql_query('insert into users(id, username, password, email, avatar, signup_date) values ('.$id.', "'.$username.'", "'.$password.'", "'.$email.'", "'.$avatar.'", "'.time().'")'))
{
//We dont display the form
$form = false;
?>
<div class="message">You have successfuly been signed up. You can log in.<br />
<a href="connexion.php">Log in</a></div>
<?php
}
else
{
//Otherwise, we say that an error occured
$form = true;
$message = 'An error occurred while signing up.';
}
}
else
{
//Otherwise, we say the username is not available
$form = true;
$message = 'The username you want to use is not available, please choose another one.';
}
}
else
{
//Otherwise, we say the email is not valid
$form = true;
$message = 'The email you entered is not valid.';
}
}
else
{
//Otherwise, we say the password is too short
$form = true;
$message = 'Your password must contain at least 6 characters.';
}
}
else
{
//Otherwise, we say the passwords are not identical
$form = true;
$message = 'The passwords you entered are not identical.';
}
}
else
{
$form = true;
}
if($form)
{
//We display a message if necessary
if(isset($message))
{
echo '<div class="message">'.$message.'</div>';
}
//We display the form
?>
//We check if the form has been sent
if(isset($_POST['username'], $_POST['password'], $_POST['passverif'], $_POST['email'], $_POST['avatar']) and $_POST['username']!='')
{
//We remove slashes depending on the configuration
if(get_magic_quotes_gpc())
{
$_POST['username'] = stripslashes($_POST['username']);
$_POST['password'] = stripslashes($_POST['password']);
$_POST['passverif'] = stripslashes($_POST['passverif']);
$_POST['email'] = stripslashes($_POST['email']);
$_POST['avatar'] = stripslashes($_POST['avatar']);
}
//We check if the two passwords are identical
if($_POST['password']==$_POST['passverif'])
{
//We check if the password has 6 or more characters
if(strlen($_POST['password'])>=6)
{
//We check if the email form is valid
if(preg_match('#^(([a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+\.?)*[a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+)@(([a-z0-9-_]+\.?)*[a-z0-9-_]+)\.[a-z]{2,}$#i',$_POST['email']))
{
//We protect the variables
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$email = mysql_real_escape_string($_POST['email']);
$avatar = mysql_real_escape_string($_POST['avatar']);
//We check if there is no other user using the same username
$dn = mysql_num_rows(mysql_query('select id from users where username="'.$username.'"'));
if($dn==0)
{
//We count the number of users to give an ID to this one
$dn2 = mysql_num_rows(mysql_query('select id from users'));
$id = $dn2+1;
//We save the informations to the databse
if(mysql_query('insert into users(id, username, password, email, avatar, signup_date) values ('.$id.', "'.$username.'", "'.$password.'", "'.$email.'", "'.$avatar.'", "'.time().'")'))
{
//We dont display the form
$form = false;
?>
<div class="message">You have successfuly been signed up. You can log in.<br />
<a href="connexion.php">Log in</a></div>
<?php
}
else
{
//Otherwise, we say that an error occured
$form = true;
$message = 'An error occurred while signing up.';
}
}
else
{
//Otherwise, we say the username is not available
$form = true;
$message = 'The username you want to use is not available, please choose another one.';
}
}
else
{
//Otherwise, we say the email is not valid
$form = true;
$message = 'The email you entered is not valid.';
}
}
else
{
//Otherwise, we say the password is too short
$form = true;
$message = 'Your password must contain at least 6 characters.';
}
}
else
{
//Otherwise, we say the passwords are not identical
$form = true;
$message = 'The passwords you entered are not identical.';
}
}
else
{
$form = true;
}
if($form)
{
//We display a message if necessary
if(isset($message))
{
echo '<div class="message">'.$message.'</div>';
}
//We display the form
?>
Het gaat hier om een Member pagina waar een link moet komen naar zijn profile.
Toevoeging op 04/04/2016 13:34:33:
Het rare er van is dat er ook een userlist bestaat waar ook een zelfde soort code word gebruikt.
Maar als ik die code in de indext.php plaats dan werkt het niet.
Dit is de userlist pagina:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
//If the user is logged, we display links to edit his infos, to see his pms and to log out
if(isset($_SESSION['username']))
{
?>
This is the list of members:
<table>
<tr>
<th>Id</th>
<th>Username</th>
<th>Email</th>
</tr>
<?php
//We get the IDs, usernames and emails of users
$req = mysql_query('select id, username, email from users');
while($dnn = mysql_fetch_array($req))
{
?>
<tr>
<td class="left"><?php echo $dnn['id']; ?></td>
<td class="left"><a href="profile.php?id=<?php echo $dnn['id']; ?>"><?php echo htmlentities($dnn['username'], ENT_QUOTES, 'UTF-8'); ?></a></td>
<td class="left"><?php echo htmlentities($dnn['email'], ENT_QUOTES, 'UTF-8'); ?></td>
</tr>
<?php
}
?>
</table>
<?php
}
else
{
//Otherwise, we display a link to log in and to Sign up
echo "<br/><br /><p align='center'>Need to <a href='connexion.php'>Login</a> to see the Users list.</p><br /><br />";
?>
<?php
}
?>
//If the user is logged, we display links to edit his infos, to see his pms and to log out
if(isset($_SESSION['username']))
{
?>
This is the list of members:
<table>
<tr>
<th>Id</th>
<th>Username</th>
<th>Email</th>
</tr>
<?php
//We get the IDs, usernames and emails of users
$req = mysql_query('select id, username, email from users');
while($dnn = mysql_fetch_array($req))
{
?>
<tr>
<td class="left"><?php echo $dnn['id']; ?></td>
<td class="left"><a href="profile.php?id=<?php echo $dnn['id']; ?>"><?php echo htmlentities($dnn['username'], ENT_QUOTES, 'UTF-8'); ?></a></td>
<td class="left"><?php echo htmlentities($dnn['email'], ENT_QUOTES, 'UTF-8'); ?></td>
</tr>
<?php
}
?>
</table>
<?php
}
else
{
//Otherwise, we display a link to log in and to Sign up
echo "<br/><br /><p align='center'>Need to <a href='connexion.php'>Login</a> to see the Users list.</p><br /><br />";
?>
<?php
}
?>
Gewijzigd op 04/04/2016 13:38:29 door Sem Cool
Dan wordt de sessie ergens anders aangemaakt....
Een een profiel pagina is heel iets anders dan een userlist pagina. Een userlist pagina haalt alle profielen op en aan de hand van de ID word er dan een profiel getoond op de vervolg pagina (profiel pagina).
Aan de hand van je sessies maak ik op dat je niet een ID gebruikt om in te loggen maar een gebruikers naam. Dus zal de link zoiets worden:
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
<?php
$query = mysql_query('SELECT id, username FROM USERS WHERE username="'.mysql_real_escape_string($_SESSION['username']).'"');
$dn = mysql_fetch_array($query);
echo '<a href="profile.php?id='.$dn['id'].'">Mijn profiel</a>';
?>
$query = mysql_query('SELECT id, username FROM USERS WHERE username="'.mysql_real_escape_string($_SESSION['username']).'"');
$dn = mysql_fetch_array($query);
echo '<a href="profile.php?id='.$dn['id'].'">Mijn profiel</a>';
?>
Denk wel aan fout afhandeling.
Gewijzigd op 04/04/2016 14:10:35 door Joakim Broden
Nogmaals:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
//If the user is logged, we log him out
if(isset($_SESSION['username']))
{
//We log him out by deleting the username and userid sessions
unset($_SESSION['username'], $_SESSION['userid']);
?>
<div class="message">You have successfuly been loged out.<br />
<a href="<?php echo $url_home; ?>"><font color="#99ddff">Home</a></div>
<?php
}
else
{
$ousername = '';
//We check if the form has been sent
if(isset($_POST['username'], $_POST['password']))
{
//We remove slashes depending on the configuration
if(get_magic_quotes_gpc())
{
$ousername = stripslashes($_POST['username']);
$username = mysql_real_escape_string(stripslashes($_POST['username']));
$password = stripslashes($_POST['password']);
}
else
{
$username = mysql_real_escape_string($_POST['username']);
$password = $_POST['password'];
}
//We get the password of the user
$req = mysql_query('select password,id from users where username="'.$username.'"');
$dn = mysql_fetch_array($req);
//We compare the submited password and the real one, and we check if the user exists
if($dn['password']==$password and mysql_num_rows($req)>0)
{
//If the password is good, we dont show the form
$form = false;
//We save the user name in the session username and the user Id in the session userid
$_SESSION['username'] = $_POST['username'];
$_SESSION['userid'] = $dn['id'];
?>
<div class="message">You have successfuly been logged.<br />
<a href="<?php echo $url_home; ?>"><font color="#99ddff">Home</a></span></div>
<?php
}
else
{
//Otherwise, we say the password is incorrect.
$form = true;
$message = 'The username or password is incorrect.';
}
}
else
{
$form = true;
}
if($form)
{
//We display a message if necessary
if(isset($message))
{
echo '<div class="message">'.$message.'</div>';
}
//We display the form
?>
<div class="content">
<form action="connexion.php" method="post">
Please type your IDs to log in:<br /><br />
<div class="center">
<label for="username">Username</label><input type="text" name="username" id="username" value="<?php echo htmlentities($ousername, ENT_QUOTES, 'UTF-8'); ?>" /><br />
<label for="password">Password</label><input type="password" name="password" id="password" /><br />
<br /><input type="submit" value="Log in" />
</div>
</form>
</div>
<?php
}
}
?>
//If the user is logged, we log him out
if(isset($_SESSION['username']))
{
//We log him out by deleting the username and userid sessions
unset($_SESSION['username'], $_SESSION['userid']);
?>
<div class="message">You have successfuly been loged out.<br />
<a href="<?php echo $url_home; ?>"><font color="#99ddff">Home</a></div>
<?php
}
else
{
$ousername = '';
//We check if the form has been sent
if(isset($_POST['username'], $_POST['password']))
{
//We remove slashes depending on the configuration
if(get_magic_quotes_gpc())
{
$ousername = stripslashes($_POST['username']);
$username = mysql_real_escape_string(stripslashes($_POST['username']));
$password = stripslashes($_POST['password']);
}
else
{
$username = mysql_real_escape_string($_POST['username']);
$password = $_POST['password'];
}
//We get the password of the user
$req = mysql_query('select password,id from users where username="'.$username.'"');
$dn = mysql_fetch_array($req);
//We compare the submited password and the real one, and we check if the user exists
if($dn['password']==$password and mysql_num_rows($req)>0)
{
//If the password is good, we dont show the form
$form = false;
//We save the user name in the session username and the user Id in the session userid
$_SESSION['username'] = $_POST['username'];
$_SESSION['userid'] = $dn['id'];
?>
<div class="message">You have successfuly been logged.<br />
<a href="<?php echo $url_home; ?>"><font color="#99ddff">Home</a></span></div>
<?php
}
else
{
//Otherwise, we say the password is incorrect.
$form = true;
$message = 'The username or password is incorrect.';
}
}
else
{
$form = true;
}
if($form)
{
//We display a message if necessary
if(isset($message))
{
echo '<div class="message">'.$message.'</div>';
}
//We display the form
?>
<div class="content">
<form action="connexion.php" method="post">
Please type your IDs to log in:<br /><br />
<div class="center">
<label for="username">Username</label><input type="text" name="username" id="username" value="<?php echo htmlentities($ousername, ENT_QUOTES, 'UTF-8'); ?>" /><br />
<label for="password">Password</label><input type="password" name="password" id="password" /><br />
<br /><input type="submit" value="Log in" />
</div>
</form>
</div>
<?php
}
}
?>
Indien je PHP versie ten minste 5.4.0 is kan dat gezever over magic quotes er uit want die functionaliteit is vanaf dat moment verwijderd. Dit doet mij ook vermoeden dat deze code al enigszins gedateerd is.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
if(!isset($_SESSION['username']))
{
echo '<a href="connexion.php">Login |</a>';
}
else
{
echo '<a href="connexion.php">Logout |</a>';
}
?>
<a href="sign_up.php">Sign up</a> </p>
<br/>
</div></div>
<div class="content">
<?php
//We display a welcome message, if the user is logged, we display it username
?>
Hello<?php if(isset($_SESSION['username'])){echo ' '.htmlentities($_SESSION['username'], ENT_QUOTES, 'UTF-8');} ?>,<br />
Welcome.<br />
<br />
<a href="users.php">Users list</a><br />
<?php
//If the user is logged, we display links to edit his infos, to see his pms and to log out
if(isset($_SESSION['username']))
{
?>
<?php
$req = mysql_query('select id, username, email from users');
while($dnn = mysql_fetch_array($req))
?>
<a href="profile.php?id=<?php echo $dnn['id']; ?>">My Profile</a>
<br />
<a href="edit_infos.php">Edit my personal informations</a><br />
<br />
<a href="sounds.php">Sounds</a><br />
<?php
}
else
{
//Otherwise, we display a link to log in and to Sign up
?>
<a href="sign_up.php">Sign up</a><br />
<a href="connexion.php">Log in</a>
<?php
}
?>
if(!isset($_SESSION['username']))
{
echo '<a href="connexion.php">Login |</a>';
}
else
{
echo '<a href="connexion.php">Logout |</a>';
}
?>
<a href="sign_up.php">Sign up</a> </p>
<br/>
</div></div>
<div class="content">
<?php
//We display a welcome message, if the user is logged, we display it username
?>
Hello<?php if(isset($_SESSION['username'])){echo ' '.htmlentities($_SESSION['username'], ENT_QUOTES, 'UTF-8');} ?>,<br />
Welcome.<br />
<br />
<a href="users.php">Users list</a><br />
<?php
//If the user is logged, we display links to edit his infos, to see his pms and to log out
if(isset($_SESSION['username']))
{
?>
<?php
$req = mysql_query('select id, username, email from users');
while($dnn = mysql_fetch_array($req))
?>
<a href="profile.php?id=<?php echo $dnn['id']; ?>">My Profile</a>
<br />
<a href="edit_infos.php">Edit my personal informations</a><br />
<br />
<a href="sounds.php">Sounds</a><br />
<?php
}
else
{
//Otherwise, we display a link to log in and to Sign up
?>
<a href="sign_up.php">Sign up</a><br />
<a href="connexion.php">Log in</a>
<?php
}
?>
Ik zal nu even kijken naar de reacties of ik daar iets uit kan halen om dit op te lossen.
Mvg.
Toevoeging op 04/04/2016 14:06:22:
En dit is trouwens de profile.php:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
//We check if the users ID is defined
if(isset($_GET['id']))
{
$id = intval($_GET['id']);
//We check if the user exists
$dn = mysql_query('select username, email, avatar, signup_date from users where id="'.$id.'"');
if(mysql_num_rows($dn)>0)
{
$dnn = mysql_fetch_array($dn);
//We display the user datas
?>
This is the profile of "<?php echo htmlentities($dnn['username']); ?>" :
<table style="width:450px;">
<tr>
<td><?php
if($dnn['avatar']!='')
{
echo '<img src="'.htmlentities($dnn['avatar'], ENT_QUOTES, 'UTF-8').'" alt="Avatar" style="max-width:80px;max-height:80px;" />';
}
else
{
echo 'This user dont have an avatar.';
}
?></td>
<td class="left"><h2><?php echo htmlentities($dnn['username'], ENT_QUOTES, 'UTF-8'); ?></h2>
Email: <?php echo htmlentities($dnn['email'], ENT_QUOTES, 'UTF-8'); ?><br />
This user joined on <?php echo date('d/m/Y',$dnn['signup_date']); ?></td>
</tr>
</table>
<?php
}
else
{
echo 'This user dont exists.';
}
}
else
{
echo 'The user ID is not defined.';
}
?>
//We check if the users ID is defined
if(isset($_GET['id']))
{
$id = intval($_GET['id']);
//We check if the user exists
$dn = mysql_query('select username, email, avatar, signup_date from users where id="'.$id.'"');
if(mysql_num_rows($dn)>0)
{
$dnn = mysql_fetch_array($dn);
//We display the user datas
?>
This is the profile of "<?php echo htmlentities($dnn['username']); ?>" :
<table style="width:450px;">
<tr>
<td><?php
if($dnn['avatar']!='')
{
echo '<img src="'.htmlentities($dnn['avatar'], ENT_QUOTES, 'UTF-8').'" alt="Avatar" style="max-width:80px;max-height:80px;" />';
}
else
{
echo 'This user dont have an avatar.';
}
?></td>
<td class="left"><h2><?php echo htmlentities($dnn['username'], ENT_QUOTES, 'UTF-8'); ?></h2>
Email: <?php echo htmlentities($dnn['email'], ENT_QUOTES, 'UTF-8'); ?><br />
This user joined on <?php echo date('d/m/Y',$dnn['signup_date']); ?></td>
</tr>
</table>
<?php
}
else
{
echo 'This user dont exists.';
}
}
else
{
echo 'The user ID is not defined.';
}
?>
Toevoeging op 04/04/2016 14:31:18:
Ik weet niet hoe maar het is gelukt met:
Eindelijk na zoveel weken, Bedankt alle....
Gewijzigd op 04/04/2016 14:03:45 door Sem Cool
Gewijzigd op 04/04/2016 17:00:55 door Marthijn Buijs
Ik zie nergens een session_start() staan.