captcha vraagje

Gestart doorRobindb84 reacties432 weergaven

85 berichten · pagina 4 van 6

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Aarclay schreef:
Waarom schrijf je $id over?
Waarom niet, ik doe verder toch niks met $q dus kan ik het ook wel overschreven worden.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
$id = $mysql->query("SELECT id, username FROM users WHERE username = ".$mysql->real_escape_string($_POST[username])." LIMIT 1"); 
$id = $id->fetch_assoc();


Ten eerste komt er een result uit de query, geen id-nummer
Ten tweede schrijf je hem over, dus fetch_assoc() zal hoogstwaarschijnlijk geen result meer vinden.
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Aarclay schreef:
$id = $mysql->query("SELECT id, username FROM users WHERE username = ".$mysql->real_escape_string($_POST[username])." LIMIT 1"); 
$id = $id->fetch_assoc();
Ten eerste komt er een result uit de query, geen id-nummer
Ten tweede schrijf je hem over, dus fetch_assoc() zal hoogstwaarschijnlijk geen result meer vinden.

Wat als je meerdere queries hebt, die kan je allemaal niet $result gaan noemen, dus dan maar wat die ophaalt.

En dat 2e, dit gebruik ik vaker en het werkt gewoon:

Codeblok (voorbeeld.php):

1
2
3
4
5

$str = Aarclay,;
$str = Hoi .$str;
echo $str; // Hoi Aarclay,
?>
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Je kan ze allemaal $result noemen, als je de andere queries erboven maar niet meer nodig hebt.
0
Robindb

Lid · Topicstarter

Berichten
538
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
Houd het gewoon consistent? Niks mis mee, en het houd je script duidelijk. smile
wat moet ik nu doen precies snap het effe niet meer
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Aarclay schreef:
Je kan ze allemaal $result noemen, als je de andere queries erboven maar niet meer nodig hebt.
En als je die wel nodig hebt..
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Dan zou ik ze $r_users, $r_articles etc... noemen.
0
Robindb

Lid · Topicstarter

Berichten
538
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
nog 1 keer
hoe echo ik de username inplaats van id
dit is mijn index.php
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/require_once"]require_once[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]config.php[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/require_once"]require_once[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]rand.php[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[COLOR= #0000BB]$txt[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]]) && ![/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]])) {[/COLOR]
    
    [COLOR= #0000BB]$errors[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/trim"]trim[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700]) {[/COLOR]
        [COLOR= #0000BB]$errors[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #DD0000]Je hebt geen gebruikersnaam ingevuld.[/COLOR][COLOR= #007700];
    }[/COLOR]
        
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/trim"]trim[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700]) {[/COLOR]
        [COLOR= #0000BB]$errors[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #DD0000]Je hebt geen wachtwoord ingevuld.[/COLOR][COLOR= #007700];
    }[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$errors[/COLOR][COLOR= #007700]) !=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
        [COLOR= #0000BB]$txt[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<ul>[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$errors[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$error[/COLOR][COLOR= #007700]) {[/COLOR]
            [COLOR= #0000BB]$txt[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]<li>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$error[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</li>[/COLOR][COLOR= #007700];
        }[/COLOR]        
        [COLOR= #0000BB]$txt[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]</ul>[/COLOR][COLOR= #007700];
    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [COLOR= #0000BB]$q[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT COUNT(id) as founds FROM users WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" 
                                                        AND password = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/sha1"]sha1[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]])).[/COLOR][COLOR= #DD0000]"
                            LIMIT 1"[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$q[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$q[/COLOR][COLOR= #007700]->[/COLOR] fetch_assoc[COLOR= #007700]();[/COLOR]
        
        
        
        
        
        
        
          [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$q[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]founds[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
            [COLOR= #0000BB]$id[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT id, username FROM users WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" LIMIT 1"[/COLOR][COLOR= #007700]);[/COLOR]
            
            [COLOR= #0000BB]$id[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$id[/COLOR][COLOR= #007700]->[/COLOR]fetch_assoc[COLOR= #007700]();[/COLOR]
            
            
            [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$id[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR]
            [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$id[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
            
            [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Location: index.php"[/COLOR][COLOR= #007700]);
        
        }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
            [COLOR= #0000BB]$txt[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<ul><li>Je gebruikersnaam/wachtwoord komt niet overeen.</li></ul>[/COLOR][COLOR= #007700];
        }
    }
    
}[/COLOR]
?>
<!DOCTYPE html>
<html>
    <head>
        <title>Upload/download systeem</title>
        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">

        <!-- Optional theme -->
        <link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">

        <!-- Custom theme -->
        <link rel="stylesheet" type="text/css" href="./style.css">
        
        <!-- Latest compiled and minified JavaScript -->
        <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
    </head>
    
    <body>
    [COLOR= #0000BB]<?php[/COLOR]
     
     
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
    

      ?>

        <div id="container">
            [COLOR= #0000BB]<?php[/COLOR]
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]])) {[/COLOR]
            ?>
            <form action="#" method="POST" name="loginForm">
                [COLOR= #0000BB]<?php[/COLOR]
                [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/trim"]trim[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$txt[/COLOR][COLOR= #007700]) !=[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700]) {[/COLOR]
                    ?>
                    <div class="alert alert-danger">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$txt[/COLOR] ?></div>
                    [COLOR= #0000BB]<?php[/COLOR]
                [COLOR= #007700]}[/COLOR]
                
                [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]r[/COLOR][COLOR= #007700]])) {[/COLOR]
                    ?>
                    <div class="alert alert-success">Je hebt succesvol een account aangemaakt!</div>
                    [COLOR= #0000BB]<?php[/COLOR]
                [COLOR= #007700]}[/COLOR]
                ?>
                <div class="input-group">
                  <span class="input-group-addon">Gebruikersnaam</span>
                  <input type="text" class="form-control" placeholder="Gebruikersnaam" name="username">
                </div>
                
                <div class="input-group">
                  <span class="input-group-addon">Wachtwoord</span>
                  <input type="password" class="form-control" placeholder="*******" name="password">
                </div>
                <button type="submit" class="btn btn-success btn-large right"><i class="icon-white icon-heart"></i> Log in</button>
                <a href="./register.php" class="btn btn-success btn-large"><i class="icon-white icon-heart"></i> Registeren</a>
            </form>
            [COLOR= #0000BB]<?php[/COLOR]
            [COLOR= #007700]}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]d[/COLOR][COLOR= #007700]])) {[/COLOR]
                    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"DELETE FROM files WHERE id = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]d[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700])) {[/COLOR]
                        ?>
                            <div class="alert alert-success">Succesvol verwijderd.</div>
                        [COLOR= #0000BB]<?php[/COLOR]
                    [COLOR= #007700]}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                        ?>
                            <div class="alert alert-danger">Mislukt, probeer het nogmaals.</div>
                        [COLOR= #0000BB]<?php[/COLOR]
                    [COLOR= #007700]}
                }[/COLOR]

                [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]file[/COLOR][COLOR= #007700]])) {[/COLOR]
            
                    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]file[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]error[/COLOR][COLOR= #007700]] >[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
                    ?>
                        <div class="alert alert-danger">Mislukt, probeer het nogmaals.</div>
                    [COLOR= #0000BB]<?php[/COLOR]
                    [COLOR= #007700]}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                    [COLOR= #0000BB]$ext[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/explode"]explode[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000].[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]file[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]]);[/COLOR]
                        [COLOR= #0000BB]$rand[/COLOR] [COLOR= #007700]= new[/COLOR] [URL="http://www.php.net/Rand"]Rand[/URL][COLOR= #007700];[/COLOR]
                        [COLOR= #0000BB]$fileName[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$rand[/COLOR][COLOR= #007700]->[/COLOR]randFileName[COLOR= #007700]([/COLOR][COLOR= #DD0000]./uploads/[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/end"]end[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$ext[/COLOR][COLOR= #007700]));[/COLOR]
                        [COLOR= #0000BB]$u[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO files(uId, fileName, baseName) 
                                                        VALUES("[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$fileName[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]file[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]")"[/COLOR][COLOR= #007700]);[/COLOR]
                        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/move_uploaded_file"]move_uploaded_file[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]file[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]tmp_name[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #DD0000]./uploads/[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$fileName[/COLOR][COLOR= #007700]) &&[/COLOR] [COLOR= #0000BB]$u[/COLOR][COLOR= #007700]) {[/COLOR]
                        ?>
                            <div class="alert alert-success">Succesvol geupload.</div>
                        [COLOR= #0000BB]<?php[/COLOR]
                        [COLOR= #007700]}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                            ?>
                            <div class="alert alert-danger">Mislukt, probeer het nogmaals.</div>
                            [COLOR= #0000BB]<?php[/COLOR]
                        [COLOR= #007700]}
                    }
                }[/COLOR]
                
                [COLOR= #0000BB]$files[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT id, fileName, baseName FROM files WHERE uId = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
            ?>
            
            <form id="uploadForm" action="index.php" method="POST" enctype=multipart/form-data>
                <input type="file">
                <button type="submit" value="Upload" class="btn btn-success"><span class="glyphicon glyphicon-cloud-upload">upload</span></button>
                <a href="logout.php" class="btn btn-danger"><span class="glyphicon glyphicon-expand"></span>uitloggen</a>
            </form>
            
            [COLOR= #0000BB]<?php[/COLOR]
                [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$file[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$files[/COLOR][COLOR= #007700]->[/COLOR]fetch_assoc[COLOR= #007700]()) {[/COLOR]
                    ?>
                    <div class="well">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$file[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]baseName[/COLOR][COLOR= #007700]],[/COLOR] ENT_QUOTES[COLOR= #007700])[/COLOR] ?>  <input type="text" class="form-control" value="http://[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]HTTP_HOST[/COLOR][COLOR= #007700]][/COLOR]?>/d/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$file[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fileName[/COLOR][COLOR= #007700]],[/COLOR] ENT_QUOTES[COLOR= #007700]);[/COLOR] ?>"/><button type="button" onclick="if(confirm(Weet je zeker dat je deze download wilt verwijderen?)) { window.location=./?d=[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$file[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]][/COLOR] ?> }"class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-remove"></span></button><button type="button" onclick="window.location=./d/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$file[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fileName[/COLOR][COLOR= #007700]],[/COLOR] ENT_QUOTES[COLOR= #007700]);[/COLOR] ?>"><span class="glyphicon glyphicon-download-alt"></span></button></div>
                    [COLOR= #0000BB]<?php[/COLOR]
                [COLOR= #007700]}
            }[/COLOR]
            ?>
        </div>
    </body>
</html>
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Dylanh schreef:
Codeblok (voorbeeld.php):
1
2
3
4
5
6
7
8
9
10
11

if($q[founds] != 0) {
$id = $mysql->query("SELECT id, username FROM users WHERE username = ".$mysql->real_escape_string($_POST[username])." LIMIT 1");

$id = $id->fetch_assoc();

$_SESSION[id] = $id[id];
$_SESSION[username] = $id[username];

header("Location: index.php");
}
0
Robindb

Lid · Topicstarter

Berichten
538
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Robindb schreef:
nog 1 keer
hoe echo ik de username inplaats van id
dit is mijn index.php
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/require_once"]require_once[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]config.php[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/require_once"]require_once[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]rand.php[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[COLOR= #0000BB]$txt[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]]) && ![/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]])) {[/COLOR]
    
    [COLOR= #0000BB]$errors[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/trim"]trim[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700]) {[/COLOR]
        [COLOR= #0000BB]$errors[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #DD0000]Je hebt geen gebruikersnaam ingevuld.[/COLOR][COLOR= #007700];
    }[/COLOR]

        
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/trim"]trim[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700]) {[/COLOR]
        [COLOR= #0000BB]$errors[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #DD0000]Je hebt geen wachtwoord ingevuld.[/COLOR][COLOR= #007700];
    }[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$errors[/COLOR][COLOR= #007700]) !=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
        [COLOR= #0000BB]$txt[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<ul>[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$errors[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$error[/COLOR][COLOR= #007700]) {[/COLOR]
            [COLOR= #0000BB]$txt[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]<li>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$error[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</li>[/COLOR][COLOR= #007700];
        }[/COLOR]        
        [COLOR= #0000BB]$txt[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]</ul>[/COLOR][COLOR= #007700];
    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [COLOR= #0000BB]$q[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT COUNT(id) as founds FROM users WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" 
                                                        AND password = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/sha1"]sha1[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]])).[/COLOR][COLOR= #DD0000]"
                            LIMIT 1"[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$q[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$q[/COLOR][COLOR= #007700]->[/COLOR] fetch_assoc[COLOR= #007700]();[/COLOR]
        
        
        
        
        
        
        
          [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$q[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]founds[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
            [COLOR= #0000BB]$id[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT id, username FROM users WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" LIMIT 1"[/COLOR][COLOR= #007700]);[/COLOR]
            
            [COLOR= #0000BB]$id[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$id[/COLOR][COLOR= #007700]->[/COLOR]fetch_assoc[COLOR= #007700]();[/COLOR]
            
            
            [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$id[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR]
            [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$id[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
            
            [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Location: index.php"[/COLOR][COLOR= #007700]);
        
        }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
            [COLOR= #0000BB]$txt[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<ul><li>Je gebruikersnaam/wachtwoord komt niet overeen.</li></ul>[/COLOR][COLOR= #007700];
        }
    }
    
}[/COLOR]
?>
<!DOCTYPE html>
<html>
    <head>
        <title>Upload/download systeem</title>
        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">

        <!-- Optional theme -->
        <link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">

        <!-- Custom theme -->
        <link rel="stylesheet" type="text/css" href="./style.css">
        
        <!-- Latest compiled and minified JavaScript -->
        <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
    </head>
    
    <body>
    [COLOR= #0000BB]<?php[/COLOR]
     
     
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
    

      ?>

        <div id="container">
            [COLOR= #0000BB]<?php[/COLOR]
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]])) {[/COLOR]
            ?>
            <form action="#" method="POST" name="loginForm">
                [COLOR= #0000BB]<?php[/COLOR]
                [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/trim"]trim[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$txt[/COLOR][COLOR= #007700]) !=[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700]) {[/COLOR]
                    ?>
                    <div class="alert alert-danger">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$txt[/COLOR] ?></div>
                    [COLOR= #0000BB]<?php[/COLOR]
                [COLOR= #007700]}[/COLOR]
                
                [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]r[/COLOR][COLOR= #007700]])) {[/COLOR]
                    ?>
                    <div class="alert alert-success">Je hebt succesvol een account aangemaakt!</div>
                    [COLOR= #0000BB]<?php[/COLOR]
                [COLOR= #007700]}[/COLOR]
                ?>
                <div class="input-group">
                  <span class="input-group-addon">Gebruikersnaam</span>
                  <input type="text" class="form-control" placeholder="Gebruikersnaam" name="username">
                </div>
                
                <div class="input-group">
                  <span class="input-group-addon">Wachtwoord</span>
                  <input type="password" class="form-control" placeholder="*******" name="password">
                </div>
                <button type="submit" class="btn btn-success btn-large right"><i class="icon-white icon-heart"></i> Log in</button>
                <a href="./register.php" class="btn btn-success btn-large"><i class="icon-white icon-heart"></i> Registeren</a>
            </form>
            [COLOR= #0000BB]<?php[/COLOR]
            [COLOR= #007700]}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]d[/COLOR][COLOR= #007700]])) {[/COLOR]
                    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"DELETE FROM files WHERE id = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]d[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700])) {[/COLOR]
                        ?>
                            <div class="alert alert-success">Succesvol verwijderd.</div>
                        [COLOR= #0000BB]<?php[/COLOR]
                    [COLOR= #007700]}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                        ?>
                            <div class="alert alert-danger">Mislukt, probeer het nogmaals.</div>
                        [COLOR= #0000BB]<?php[/COLOR]
                    [COLOR= #007700]}
                }[/COLOR]

                [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]file[/COLOR][COLOR= #007700]])) {[/COLOR]
            
                    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]file[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]error[/COLOR][COLOR= #007700]] >[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
                    ?>
                        <div class="alert alert-danger">Mislukt, probeer het nogmaals.</div>
                    [COLOR= #0000BB]<?php[/COLOR]
                    [COLOR= #007700]}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                    [COLOR= #0000BB]$ext[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/explode"]explode[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000].[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]file[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]]);[/COLOR]
                        [COLOR= #0000BB]$rand[/COLOR] [COLOR= #007700]= new[/COLOR] [URL="http://www.php.net/Rand"]Rand[/URL][COLOR= #007700];[/COLOR]
                        [COLOR= #0000BB]$fileName[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$rand[/COLOR][COLOR= #007700]->[/COLOR]randFileName[COLOR= #007700]([/COLOR][COLOR= #DD0000]./uploads/[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/end"]end[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$ext[/COLOR][COLOR= #007700]));[/COLOR]
                        [COLOR= #0000BB]$u[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO files(uId, fileName, baseName) 
                                                        VALUES("[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$fileName[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]file[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]")"[/COLOR][COLOR= #007700]);[/COLOR]
                        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/move_uploaded_file"]move_uploaded_file[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]file[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]tmp_name[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #DD0000]./uploads/[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$fileName[/COLOR][COLOR= #007700]) &&[/COLOR] [COLOR= #0000BB]$u[/COLOR][COLOR= #007700]) {[/COLOR]
                        ?>
                            <div class="alert alert-success">Succesvol geupload.</div>
                        [COLOR= #0000BB]<?php[/COLOR]
                        [COLOR= #007700]}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                            ?>
                            <div class="alert alert-danger">Mislukt, probeer het nogmaals.</div>
                            [COLOR= #0000BB]<?php[/COLOR]
                        [COLOR= #007700]}
                    }
                }[/COLOR]
                
                [COLOR= #0000BB]$files[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT id, fileName, baseName FROM files WHERE uId = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
            ?>
            
            <form id="uploadForm" action="index.php" method="POST" enctype=multipart/form-data>
                <input type="file">
                <button type="submit" value="Upload" class="btn btn-success"><span class="glyphicon glyphicon-cloud-upload">upload</span></button>
                <a href="logout.php" class="btn btn-danger"><span class="glyphicon glyphicon-expand"></span>uitloggen</a>
            </form>
            
            [COLOR= #0000BB]<?php[/COLOR]
                [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$file[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$files[/COLOR][COLOR= #007700]->[/COLOR]fetch_assoc[COLOR= #007700]()) {[/COLOR]
                    ?>
                    <div class="well">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$file[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]baseName[/COLOR][COLOR= #007700]],[/COLOR] ENT_QUOTES[COLOR= #007700])[/COLOR] ?>  <input type="text" class="form-control" value="http://[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]HTTP_HOST[/COLOR][COLOR= #007700]][/COLOR]?>/d/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$file[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fileName[/COLOR][COLOR= #007700]],[/COLOR] ENT_QUOTES[COLOR= #007700]);[/COLOR] ?>"/><button type="button" onclick="if(confirm(Weet je zeker dat je deze download wilt verwijderen?)) { window.location=./?d=[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$file[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]][/COLOR] ?> }"class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-remove"></span></button><button type="button" onclick="window.location=./d/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$file[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fileName[/COLOR][COLOR= #007700]],[/COLOR] ENT_QUOTES[COLOR= #007700]);[/COLOR] ?>"><span class="glyphicon glyphicon-download-alt"></span></button></div>
                    [COLOR= #0000BB]<?php[/COLOR]
                [COLOR= #007700]}
            }[/COLOR]
            ?>
        </div>
    </body>
</html>


wat moet ik hierin veranderen om die username inplaats van die id via echo te krijgen?
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
je kan die username toch in een sessie opslaan?

En anders staat die toch in je fetch-assoc( nog steeds die q, wat is er mis met fatsoenlijke naamgeving?????)
0
Robindb

Lid · Topicstarter

Berichten
538
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
je kan die username toch in een sessie opslaan?

En anders staat die toch in je fetch-assoc( nog steeds die q, wat is er mis met fatsoenlijke naamgeving?????)
1 hoe
2 is dit beter
Spoiler tonen
$result = $mysql->query("SELECT COUNT(id) as founds FROM users WHERE username = ".$mysql->real_escape_string($_POST[username])." 
                                                        AND password = ".sha1($mysql->real_escape_string($_POST[password]))."
                            LIMIT 1");
        $data = $result->fetch_assoc();
        
        
        
        
        
        
        
         if($q[founds] != 0) {
            $result = $mysql->query("SELECT id, username FROM users WHERE username = ".$mysql->real_escape_string($_POST[username])." LIMIT 1");
            
            
            $data = $result->fetch_assoc();
            
            
            $_SESSION[id] = $id[id];
            $_SESSION[id] = $id[username];
            
            header("Location: index.php");
        
        
        } else {
            $txt = <ul><li>Je gebruikersnaam/wachtwoord komt niet overeen.</li></ul>;
        }
    }
    
}
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
$data = $result->fetch_assoc();
                      
$_SESSION[id] = $id[id];
$_SESSION[id] = $id[username];


Moet je alleen geen $id gebruiken natuurlijk
0
Robindb

Lid · Topicstarter

Berichten
538
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
is dit beter sorry dat ik zo slecht hierin ben bloos
$data = $result->fetch_assoc();
            
            
            $_SESSION[id] = $result[id];
            $_SESSION[id] = $result[username];
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Waarom $result?
Gewoon logisch kijken en weten wat je script doet.
Weet je dat niet, stop het dan even in de ijskast en begin bij een tutorial.
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren