Kleine Vragen Topic #2

Gestart doorKingunit3.067 reacties11.764 weergaven

3.068 berichten · pagina 65 van 205

Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
En weet je ook wat md5() doet?
Niet verwonderlijk dat je script je login niet accepteert.
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oooh ja, ik vergeet bij het aanmelden mijn passwoord te hashen;

En het zou sha1 moeten worden.

Dat regel ik morgen allemaal.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Sha1 met salt. Bcrypt is nog beter. .
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
En mag ik vragen waarom die beter zijn dan md5?

Is md5 nog niet 100% veilig!
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Niet MEER veilig.....
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Als ik een TABLE shouts heb

en dat bestaat uit de kollomen

Auteur - Shout - Datum

En stel ik zit op de pagina mijnschouts.php

en $username = "Sander";

Hoe zorg ik dan dat hij alle shouts weergeeft, waarbij auteur "Sander" is?
0
Berichten
1.871
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sanderc schreef:
Als ik een TABLE shouts heb

en dat bestaat uit de kollomen

Auteur - Shout - Datum
En stel ik zit op de pagina mijnschouts.php

en $username = "Sander";

Hoe zorg ik dan dat hij alle shouts weergeeft, waarbij auteur "Sander" is?

Zo?

[COLOR= #0000BB]<?php
$username[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Sander"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM shouts WHERE auteur = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])) {[/COLOR]
     [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$result[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]shout[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]<br />[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]Geplaatst op [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]datum[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] door [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]auteur[/COLOR][COLOR= #007700]];
}[/COLOR]

?>
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Try...
"Trial and error" ftw

Waarom probeer je het niet eerst?
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Ik heb deze code:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/require_once"]require_once[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]../db.connection.php[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/require_once"]require_once[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]../pass.crypt.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]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]usernameb[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]emailb[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]passwordb[/COLOR][COLOR= #007700]])){[/COLOR]
    [COLOR= #0000BB]$aQuery[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$mysqli[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM leden WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysqli[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$aQuery[/COLOR][COLOR= #007700]->[/COLOR]nuw_rows [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]) {[/COLOR]
            [COLOR= #0000BB]$aFetch[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$aQuery[/COLOR][COLOR= #007700]->[/COLOR]fetch_array[COLOR= #007700]([/COLOR]MYSQLI_ASSOC[COLOR= #007700]);[/COLOR]
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$aFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]Upassword[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]passwordb[/COLOR][COLOR= #007700]]) {[/COLOR]
                [COLOR= #0000BB]$password[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$aFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]Upassword[/COLOR][COLOR= #007700]];
            }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                [COLOR= #0000BB]$password[/COLOR] [COLOR= #007700]=[/COLOR] encrypt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]passwordb[/COLOR][COLOR= #007700]]);
            }[/COLOR]    
            [COLOR= #0000BB]$bQuery[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$mysqli[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE leden SET username = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysqli[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]usernameb[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]", Upassword = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysqli[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]", email = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysqli[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]emailb[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysqli[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
            
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bQuery[/COLOR][COLOR= #007700]) {[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Gebruiker succesvol aangepast[/COLOR][COLOR= #007700];
            }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Database fout: [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysqli[/COLOR][COLOR= #007700]->[/COLOR]error[COLOR= #007700].[/COLOR][COLOR= #DD0000]. <br />Exuses voor het ongemak.[/COLOR][COLOR= #007700];
            }
        }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Gebruiker bestaat niet.[/COLOR][COLOR= #007700];
    
        }
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[COLOR= #FF8000]//header(location: /admin/edit.php);[/COLOR]
[URL="http://www.php.net/print_r"]print_r[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700]);
}[/COLOR]

?>


Als ik nu naar deze pagina ga met ?username=hoi erachter zegt die dat de gebruiker niet bestaat terwijl dat wel zo is.

Database:
Afbeelding

Wat ik al heb geprobeerd:
- De query te echo en. (output: SELECT * FROM leden WHERE username = hoi)
- foutafhandeling op $aQuery(output: geen error)

Dus zien jullie de fout? Of wat kan ik nog meer doen om de fout te ontdekken?
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
$aQuery->nuw_rows

Ik weet verder niet hoe je class in elkaar zit, maar ik denk dat het zo moet:
$mysqli->num_rows($aQuery)

of:

$aQuery->num_rows
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Milan schreef:
$aQuery->nuw_rows

Ik weet verder niet hoe je class in elkaar zit, maar ik denk dat het zo moet:
$mysqli->num_rows($aQuery)

of:

$aQuery->num_rows
Oh. lol. Waarom kreeg ik daar geen error? -.-
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Errors staan misschien uit? Heb je in de error log gekeken?
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Heb nu ini_set(display_errors, On);
error_reporting(E_ALL);

in db.connection.php gezet. Hopelijk werken de errors nu wel.
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Het meest handige is om in de error logs te kijken, alhoewel daar soms ook niet alles in staat..
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Ik heb nu een nieuw probleempje:

[COLOR= #0000BB]<?php
$ftp_server[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/ftp_connect"]ftp_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]xxx.s2.one2xs.com[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$ftp_user[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/ftp_login"]ftp_login[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$ftp_server[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]xxx[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]xxx[/COLOR][COLOR= #007700]);[/COLOR]


[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$ftp_server[/COLOR] [COLOR= #007700]&&[/COLOR] [COLOR= #0000BB]$ftp_user[/COLOR][COLOR= #007700]) {

}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Kan niet met de FTP service verbinden.[/COLOR][COLOR= #007700];
}[/COLOR]
?>


Hoe kan ik nu:
- alle files en folders ophalen en laten zien (die in public_html staan)
- een file/folder verwijderen
- een file/folder script veranderen
?
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