Session Username in form
Login.php voor session info enz.
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 (!session_is_registered('loginid') || !session_is_registered('username'))
{
// user is not logged in.
if (isset($_POST['cmdlogin']))
{
// retrieve the username and password sent from login form
// First we remove all HTML-tags and PHP-tags, then we create a md5-hash
// This step will make sure the script is not vurnable to sql injections.
$u = strip_tags($_POST['username']);
$p = (strip_tags($_POST['password']));
//Now let us look for the user in the database.
$query = sprintf("SELECT acct FROM accounts WHERE login = '%s' AND password = '%s' LIMIT 1;",
mysql_real_escape_string($u), mysql_real_escape_string($p));
$result = mysql_query($query);
// If the database returns a 0 as result we know the login information is incorrect.
// If the database returns a 1 as result we know the login was correct and we proceed.
// If the database returns a result > 1 there are multple users
// with the same username and password, so the login will fail.
if (mysql_num_rows($result) != 1)
{
// invalid login information
echo "Wrong username or password!";
//show the loginform again.
include "loginform.php";
} else {
// Login was successfull
$row = mysql_fetch_array($result);
// Save the user ID for use later
$_SESSION['loginid'] = $row['loginid'];
// Save the username for use later
$_SESSION['username'] = $u;
// Now we show the userbox
show_userbox();
}
} else {
// User is not logged in and has not pressed the login button
// so we show him the loginform
include "loginform.php";
}
} else {
// The user is already loggedin, so we show the userbox.
show_userbox();
}
?>
if (!session_is_registered('loginid') || !session_is_registered('username'))
{
// user is not logged in.
if (isset($_POST['cmdlogin']))
{
// retrieve the username and password sent from login form
// First we remove all HTML-tags and PHP-tags, then we create a md5-hash
// This step will make sure the script is not vurnable to sql injections.
$u = strip_tags($_POST['username']);
$p = (strip_tags($_POST['password']));
//Now let us look for the user in the database.
$query = sprintf("SELECT acct FROM accounts WHERE login = '%s' AND password = '%s' LIMIT 1;",
mysql_real_escape_string($u), mysql_real_escape_string($p));
$result = mysql_query($query);
// If the database returns a 0 as result we know the login information is incorrect.
// If the database returns a 1 as result we know the login was correct and we proceed.
// If the database returns a result > 1 there are multple users
// with the same username and password, so the login will fail.
if (mysql_num_rows($result) != 1)
{
// invalid login information
echo "Wrong username or password!";
//show the loginform again.
include "loginform.php";
} else {
// Login was successfull
$row = mysql_fetch_array($result);
// Save the user ID for use later
$_SESSION['loginid'] = $row['loginid'];
// Save the username for use later
$_SESSION['username'] = $u;
// Now we show the userbox
show_userbox();
}
} else {
// User is not logged in and has not pressed the login button
// so we show him the loginform
include "loginform.php";
}
} else {
// The user is already loggedin, so we show the userbox.
show_userbox();
}
?>
Dit is dan de form: (het moet bij value komen)
Ik heb verschillende dingen geprobeert zoals:
- $_SESSION['username'] & $_SESSION['login']
- echo $_SESSION['username'] &$_SESSION['login']
- $u
Maar ik kom er maar niet uit hoe ik dat moet fixen.
Trouwens in de header heb ik:
Code (php)
1
2
3
4
5
6
2
3
4
5
6
<?php
// Start a session
session_start();
require_once ('db_connect.inc.php');
require_once ("functions.inc.php");
?>
// Start a session
session_start();
require_once ('db_connect.inc.php');
require_once ("functions.inc.php");
?>
db_connect.inc.php = Alleen mijn Database gegevens enz
functions.inc.php =
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
function show_userbox()
{
// retrieve the session information
$u = $_SESSION['username'];
$uid = $_SESSION['loginid'];
// display the user box
echo "<div id='userbox'><br>
<center>Welcome back $u!</center></div>
<div id='container'><br><br><br>
<center> <a href='./logout.php'>Logout </center>
</div>";
}
?>
function show_userbox()
{
// retrieve the session information
$u = $_SESSION['username'];
$uid = $_SESSION['loginid'];
// display the user box
echo "<div id='userbox'><br>
<center>Welcome back $u!</center></div>
<div id='container'><br><br><br>
<center> <a href='./logout.php'>Logout </center>
</div>";
}
?>
Ik weet alleen niet of dit dan wel genoeg is en of dit dan wel de session registreerd. Misschien moet ik wat van login.php includen.
Alvast bedankt voor het helpen!
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
function Naam($userid)
{
$sql = "SELECT id,voornaam,tussenvoegsels,achternaam FROM gebruikers WHERE id='".mysql_real_escape_string($userid)."'";
$query = mysql_query($sql) or die (mysql_error ());
$row = mysql_fetch_assoc($query);
if(mysql_num_rows($query) == 0){
$naam = '<font color="#FF0000">Naam niet gevonden.</font>';
}else{
$naam = ucfirst($row['voornaam']);
if(!$row['tussenvoegsels'] == ""){
$naam .= ' '.$row['tussenvoegsels'];
}
$naam .= ' '.ucfirst($row['achternaam']);
}
return $naam;
}
echo '<td><input type="HIDDEN" name="name" value="'.Naam($_SESSION['loginID']).'"></td>';
?>
function Naam($userid)
{
$sql = "SELECT id,voornaam,tussenvoegsels,achternaam FROM gebruikers WHERE id='".mysql_real_escape_string($userid)."'";
$query = mysql_query($sql) or die (mysql_error ());
$row = mysql_fetch_assoc($query);
if(mysql_num_rows($query) == 0){
$naam = '<font color="#FF0000">Naam niet gevonden.</font>';
}else{
$naam = ucfirst($row['voornaam']);
if(!$row['tussenvoegsels'] == ""){
$naam .= ' '.$row['tussenvoegsels'];
}
$naam .= ' '.ucfirst($row['achternaam']);
}
return $naam;
}
echo '<td><input type="HIDDEN" name="name" value="'.Naam($_SESSION['loginID']).'"></td>';
?>
Quote:
Parse error: syntax error, unexpected '>' in C:\xampp\htdocs\login.php on line 62
line 62:
Ik heb jou code ook verandert naar mijn database, want ik heb geen voornaam tussenvoegsels en achternaam nodig. Ik heb het niet zorgvuldig gedaan maar het is waarschijnlijk nog wel intact gebleven:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function Username($userid)
{
$sql = "SELECT login FROM accounts WHERE login='".mysql_real_escape_string($userid)."'";
$query = mysql_query($sql) or die (mysql_error ());
$row = mysql_fetch_assoc($query);
if(mysql_num_rows($query) == 0){
$naam = '<font color="#FF0000">Not registered</font>';
}else{
$naam = ucfirst($row['login']);
if(!$row['login'] == ""){
$naam .= ' '.$row['login'];
}
$naam .= ' '.ucfirst($row['login]);
}
return $username;
}
{
$sql = "SELECT login FROM accounts WHERE login='".mysql_real_escape_string($userid)."'";
$query = mysql_query($sql) or die (mysql_error ());
$row = mysql_fetch_assoc($query);
if(mysql_num_rows($query) == 0){
$naam = '<font color="#FF0000">Not registered</font>';
}else{
$naam = ucfirst($row['login']);
if(!$row['login'] == ""){
$naam .= ' '.$row['login'];
}
$naam .= ' '.ucfirst($row['login]);
}
return $username;
}
Alvast Bedankt!
Code (php)
1
2
3
2
3
<?php
echo '<td><input type="HIDDEN" name="name" value="'.($_SESSION['username']).'"></td>';
?>
echo '<td><input type="HIDDEN" name="name" value="'.($_SESSION['username']).'"></td>';
?>
:)
Vincent Huisman op 08/12/2010 22:55:03:
je bent een punt vergeten:
Code (php)
1
2
3
2
3
<?php
echo '<td><input type="HIDDEN" name="name" value="'.($_SESSION['username']).'"></td>';
?>
echo '<td><input type="HIDDEN" name="name" value="'.($_SESSION['username']).'"></td>';
?>
Die zijn nergens voor nodig.
Header.php heeft een include genaamd login.php als ik daar $u doe displayed die gewoon zonder probleem de username waarmee je ingelogged bent.
Maar als je dan naar een andere pagina gaat bijv zoals nu het geval show_news.php en dit script toevoegd krijg je niks. Hetzelfde geld als je het script toevoegd located in login.php
**Als ik een php script in header.php toevoeg word er toch ook rekening mee in gehouden door de file die is geinclude in index?
Mijn CSS doet het in iedergeval wel die is ge include in header.php ;)
Geen flauw idee.
Code (php)
1
2
3
4
5
6
2
3
4
5
6
$u = strip_tags($_POST['username']);
$p = (strip_tags($_POST['password']));
//Now let us look for the user in the database.
$query = sprintf("SELECT acct FROM accounts WHERE login = '%s' AND password = '%s' LIMIT 1;",
mysql_real_escape_string($u), mysql_real_escape_string($p));
$result = mysql_query($query);
$p = (strip_tags($_POST['password']));
//Now let us look for the user in the database.
$query = sprintf("SELECT acct FROM accounts WHERE login = '%s' AND password = '%s' LIMIT 1;",
mysql_real_escape_string($u), mysql_real_escape_string($p));
$result = mysql_query($query);
Gewijzigd op 09/12/2010 00:46:25 door Chris Broekz
Verder moet je goed kijken op welke regel de error zich bevind. Als je includes hebt, moet je het aantal regels van die include optellen bij de aantal regels van je bestand waar de fout zich bevind, vanaf het punt dat de include is.
Ik heb geen idee wat ik fout doe ik heb een test pagina gemaakt met daarin de volgende codes:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
// Start a session
session_start();
require_once ('db_connect.inc.php');
require_once ("functions.inc.php");
?>
<?php
$u = strip_tags($_POST['username']);
$p = (strip_tags($_POST['password']));
//Now let us look for the user in the database.
$query = sprintf("SELECT acct FROM accounts WHERE login = '%s' AND password = '%s' LIMIT 1;",
mysql_real_escape_string($u), mysql_real_escape_string($p));
$result = mysql_query($query);
?>
// Start a session
session_start();
require_once ('db_connect.inc.php');
require_once ("functions.inc.php");
?>
<?php
$u = strip_tags($_POST['username']);
$p = (strip_tags($_POST['password']));
//Now let us look for the user in the database.
$query = sprintf("SELECT acct FROM accounts WHERE login = '%s' AND password = '%s' LIMIT 1;",
mysql_real_escape_string($u), mysql_real_escape_string($p));
$result = mysql_query($query);
?>
Maar als ik vervolgens $u intyp bij login.php waar dit staat:
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 (!session_is_registered('loginid') || !session_is_registered('username'))
{
// user is not logged in.
if (isset($_POST['cmdlogin']))
{
// retrieve the username and password sent from login form
// First we remove all HTML-tags and PHP-tags, then we create a md5-hash
// This step will make sure the script is not vurnable to sql injections.
$u = strip_tags($_POST['username']);
$p = (strip_tags($_POST['password']));
//Now let us look for the user in the database.
$query = sprintf("SELECT acct FROM accounts WHERE login = '%s' AND password = '%s' LIMIT 1;",
mysql_real_escape_string($u), mysql_real_escape_string($p));
$result = mysql_query($query);
// If the database returns a 0 as result we know the login information is incorrect.
// If the database returns a 1 as result we know the login was correct and we proceed.
// If the database returns a result > 1 there are multple users
// with the same username and password, so the login will fail.
if (mysql_num_rows($result) != 1)
{
// invalid login information
echo "Wrong username or password!";
//show the loginform again.
include "loginform.php";
} else {
// Login was successfull
$row = mysql_fetch_array($result);
// Save the user ID for use later
$_SESSION['loginid'] = $row['loginid'];
// Save the username for use later
$_SESSION['username'] = $u;
// Now we show the userbox
show_userbox();
}
} else {
// User is not logged in and has not pressed the login button
// so we show him the loginform
include "loginform.php";
}
} else {
// The user is already loggedin, so we show the userbox.
show_userbox();
}
?>
if (!session_is_registered('loginid') || !session_is_registered('username'))
{
// user is not logged in.
if (isset($_POST['cmdlogin']))
{
// retrieve the username and password sent from login form
// First we remove all HTML-tags and PHP-tags, then we create a md5-hash
// This step will make sure the script is not vurnable to sql injections.
$u = strip_tags($_POST['username']);
$p = (strip_tags($_POST['password']));
//Now let us look for the user in the database.
$query = sprintf("SELECT acct FROM accounts WHERE login = '%s' AND password = '%s' LIMIT 1;",
mysql_real_escape_string($u), mysql_real_escape_string($p));
$result = mysql_query($query);
// If the database returns a 0 as result we know the login information is incorrect.
// If the database returns a 1 as result we know the login was correct and we proceed.
// If the database returns a result > 1 there are multple users
// with the same username and password, so the login will fail.
if (mysql_num_rows($result) != 1)
{
// invalid login information
echo "Wrong username or password!";
//show the loginform again.
include "loginform.php";
} else {
// Login was successfull
$row = mysql_fetch_array($result);
// Save the user ID for use later
$_SESSION['loginid'] = $row['loginid'];
// Save the username for use later
$_SESSION['username'] = $u;
// Now we show the userbox
show_userbox();
}
} else {
// User is not logged in and has not pressed the login button
// so we show him the loginform
include "loginform.php";
}
} else {
// The user is already loggedin, so we show the userbox.
show_userbox();
}
?>
word dat wel gedisplayed.
Hoe kan ik er voor zorgen dat bij show_news.php ook de ingelogde username word gedisplayed als ik bijvoorbeeld $u intyp?
Karl Karl op 09/12/2010 00:41:31:
Vanwaar de haakjes (())?
Die zijn nergens voor nodig.
Die zijn nergens voor nodig.
de haakjes zijn voor de om de functie op te roepen:
Code (php)
1
2
3
2
3
<?php
echo '<td><input type="HIDDEN" name="name" value="'.Naam($_SESSION['username']).'"></td>';
?>
echo '<td><input type="HIDDEN" name="name" value="'.Naam($_SESSION['username']).'"></td>';
?>
du funtie is gewoon goed :)
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
function Naam($userid)
{
$sql = "SELECT id,voornaam,tussenvoegsels,achternaam FROM gebruikers WHERE id='".mysql_real_escape_string($userid)."'";
$query = mysql_query($sql) or die (mysql_error ());
$row = mysql_fetch_assoc($query);
if(mysql_num_rows($query) == 0){
$naam = '<font color="#FF0000">Naam niet gevonden.</font>';
}else{
$naam = ucfirst($row['voornaam']);
if(!$row['tussenvoegsels'] == ""){
$naam .= ' '.$row['tussenvoegsels'];
}
$naam .= ' '.ucfirst($row['achternaam']);
}
return $naam;
}
?>
function Naam($userid)
{
$sql = "SELECT id,voornaam,tussenvoegsels,achternaam FROM gebruikers WHERE id='".mysql_real_escape_string($userid)."'";
$query = mysql_query($sql) or die (mysql_error ());
$row = mysql_fetch_assoc($query);
if(mysql_num_rows($query) == 0){
$naam = '<font color="#FF0000">Naam niet gevonden.</font>';
}else{
$naam = ucfirst($row['voornaam']);
if(!$row['tussenvoegsels'] == ""){
$naam .= ' '.$row['tussenvoegsels'];
}
$naam .= ' '.ucfirst($row['achternaam']);
}
return $naam;
}
?>
Gewijzigd op 09/12/2010 07:52:15 door Mitchel V
Ik heb het zo verandert:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
function Naam($userid)
{
$sql = "SELECT login FROM accounts WHERE acct='".mysql_real_escape_string($userid)."'";
$query = mysql_query($sql) or die (mysql_error ());
$row = mysql_fetch_assoc($query);
if(mysql_num_rows($query) == 0){
$naam = '<font color="#FF0000">Not registered</font>';
}else{
$naam = ucfirst($row['username']);
if(!$row['username'] == ""){
$naam .= ' '.$row['username'];
}
$naam .= ' '.ucfirst($row['username']);
}
return $naam;
}
?>
function Naam($userid)
{
$sql = "SELECT login FROM accounts WHERE acct='".mysql_real_escape_string($userid)."'";
$query = mysql_query($sql) or die (mysql_error ());
$row = mysql_fetch_assoc($query);
if(mysql_num_rows($query) == 0){
$naam = '<font color="#FF0000">Not registered</font>';
}else{
$naam = ucfirst($row['username']);
if(!$row['username'] == ""){
$naam .= ' '.$row['username'];
}
$naam .= ' '.ucfirst($row['username']);
}
return $naam;
}
?>
En in de header.php gezet. Met daaronder:
Code (php)
1
2
3
2
3
<?php
echo '<td><input type="HIDDEN" name="name" value="'.naam($_SESSION['username']).'"></td>';
?>
echo '<td><input type="HIDDEN" name="name" value="'.naam($_SESSION['username']).'"></td>';
?>
Hij geeft aan: Posted by: .naam($_SESSION['username']).
Ik heb LOGIN hebben in de tabel Accounts en daar is de USerID acct
En dan wil ik dat de LOGIN dat een username bevat word gedisplayed.
Mitchel V op 09/12/2010 07:50:35:
sorry voor het foutje.
de haakjes zijn voor de om de functie op te roepen:
du funtie is gewoon goed :)
de haakjes zijn voor de om de functie op te roepen:
Code (php)
1
2
3
2
3
<?php
echo '<td><input type="HIDDEN" name="name" value="'.Naam($_SESSION['username']).'"></td>';
?>
echo '<td><input type="HIDDEN" name="name" value="'.Naam($_SESSION['username']).'"></td>';
?>
du funtie is gewoon goed :)
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
function Naam($userid)
{
$sql = "SELECT id,voornaam,tussenvoegsels,achternaam FROM gebruikers WHERE id='".mysql_real_escape_string($userid)."'";
$query = mysql_query($sql) or die (mysql_error ());
$row = mysql_fetch_assoc($query);
if(mysql_num_rows($query) == 0){
$naam = '<font color="#FF0000">Naam niet gevonden.</font>';
}else{
$naam = ucfirst($row['voornaam']);
if(!$row['tussenvoegsels'] == ""){
$naam .= ' '.$row['tussenvoegsels'];
}
$naam .= ' '.ucfirst($row['achternaam']);
}
return $naam;
}
?>
function Naam($userid)
{
$sql = "SELECT id,voornaam,tussenvoegsels,achternaam FROM gebruikers WHERE id='".mysql_real_escape_string($userid)."'";
$query = mysql_query($sql) or die (mysql_error ());
$row = mysql_fetch_assoc($query);
if(mysql_num_rows($query) == 0){
$naam = '<font color="#FF0000">Naam niet gevonden.</font>';
}else{
$naam = ucfirst($row['voornaam']);
if(!$row['tussenvoegsels'] == ""){
$naam .= ' '.$row['tussenvoegsels'];
}
$naam .= ' '.ucfirst($row['achternaam']);
}
return $naam;
}
?>
Code (php)
1
2
3
4
5
6
2
3
4
5
6
<?php
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);
//rest
?>
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);
//rest
?>
session_is_registered komt uit 19 - noach gebruik de global $_SESSION
Deprecated: Function session_is_registered() is deprecated in C:\xampp\htdocs\login.php on line 2
line 2:
- SanThe - op 09/12/2010 16:19:44:
Zet dit bovenin.
Code (php)
1
2
3
4
5
6
2
3
4
5
6
<?php
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);
//rest
?>
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);
//rest
?>
Wat ik dus zei ;)
Niels Kieviet op 09/12/2010 16:42:21:
@Chris
Wat ik dus zei ;)
Wat ik dus zei ;)
Gewijzigd op 09/12/2010 22:08:27 door Chris Broekz
Het antwoord is al gegeven.
maar ik begin het idee te krijgen dat je niet veel snapt van PHP...
Ik heb een beetje uitleg bij het volgende geschreven.
Ik hoop dat je het allemaal wel weer mooi vindt -.-
Hoe moet het niet:
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
function Naam($userid)
{
//Hier geef je aan dat hij alleen login uit acounts moet lezen
$sql = "SELECT login FROM accounts WHERE acct='".mysql_real_escape_string($userid)."'";
$query = mysql_query($sql) or die (mysql_error ());
$row = mysql_fetch_assoc($query);
if(mysql_num_rows($query) == 0){
$naam = '<font color="#FF0000">Not registered</font>';
}else{
// hier haal je username uit accounts, terwijl hier boven aangegeven hebt dat hij
// alleen login uit accounts mag halen
$naam = ucfirst($row['username']);
// het zelfde
if(!$row['username'] == ""){
// het zelfde
$naam .= ' '.$row['username'];
}
// het zelfde
$naam .= ' '.ucfirst($row['username']);
}
return $naam;
}
?>
function Naam($userid)
{
//Hier geef je aan dat hij alleen login uit acounts moet lezen
$sql = "SELECT login FROM accounts WHERE acct='".mysql_real_escape_string($userid)."'";
$query = mysql_query($sql) or die (mysql_error ());
$row = mysql_fetch_assoc($query);
if(mysql_num_rows($query) == 0){
$naam = '<font color="#FF0000">Not registered</font>';
}else{
// hier haal je username uit accounts, terwijl hier boven aangegeven hebt dat hij
// alleen login uit accounts mag halen
$naam = ucfirst($row['username']);
// het zelfde
if(!$row['username'] == ""){
// het zelfde
$naam .= ' '.$row['username'];
}
// het zelfde
$naam .= ' '.ucfirst($row['username']);
}
return $naam;
}
?>
Code (php)
1
2
3
4
2
3
4
<?php
// je gebruikt naam(..) terwijl de funtie Naam(..) moet zijn.
echo '<td><input type="HIDDEN" name="name" value="'.naam($_SESSION['username']).'"></td>';
?>
// je gebruikt naam(..) terwijl de funtie Naam(..) moet zijn.
echo '<td><input type="HIDDEN" name="name" value="'.naam($_SESSION['username']).'"></td>';
?>
En zo ongeveer wel :) :
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
function Naam($userid)
{
//ik neem aan de de sessie de id krijgt van acct
$sql = "SELECT login FROM accounts WHERE acct='".mysql_real_escape_string($userid)."'";
$query = mysql_query($sql) or die (mysql_error ());
$row = mysql_fetch_assoc($query);
if(mysql_num_rows($query) == 0){
// gebruiker is wel registered want hij controleert dit alleen als er de sessie SessieNaam is.
$naam = '<font color="#FF0000">Not registered</font>';
}else{
// En ik neem aan dat login de username is..
$naam = ucfirst($row['login']);
}
return $naam;
}
?>
function Naam($userid)
{
//ik neem aan de de sessie de id krijgt van acct
$sql = "SELECT login FROM accounts WHERE acct='".mysql_real_escape_string($userid)."'";
$query = mysql_query($sql) or die (mysql_error ());
$row = mysql_fetch_assoc($query);
if(mysql_num_rows($query) == 0){
// gebruiker is wel registered want hij controleert dit alleen als er de sessie SessieNaam is.
$naam = '<font color="#FF0000">Not registered</font>';
}else{
// En ik neem aan dat login de username is..
$naam = ucfirst($row['login']);
}
return $naam;
}
?>
Code (php)
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
Zelf ook even controleren, ik ben ook niet perfect ;)