Kleine Vragen Topic #1

Gestart doorLennard4.284 reacties15.585 weergaven

4.285 berichten · pagina 250 van 286

Lennard

Lid · Topicstarter

Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
neeee dat moet je gewoon niet willen
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Lennard schreef:
neeee dat moet je gewoon niet willen
Je moet het niet willen, maar het kan wel.
0
Berichten
6.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wat is er fout aan dit stuk script?

[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR] ?>
<!DOCTYPE html>
<html>
  <head>
    <title>Sykle Control Panel - New account!</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
  </head>
  <body>
  [COLOR= #0000BB]<?php[/COLOR]
  [URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]inc/config.php[/COLOR][COLOR= #007700]);[/COLOR]
  [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR]
  [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] =[/COLOR] [URL="http://www.php.net/strtolower"]strtolower[/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]email[/COLOR][COLOR= #007700]] =[/COLOR] [URL="http://www.php.net/strtolower"]strtolower[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]);[/COLOR] 
  [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] =[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]);[/COLOR] 
  [COLOR= #0000BB]$IPCheckQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM user_users WHERE IP="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
  [COLOR= #0000BB]$UserCheckQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM user_users WHERE username="[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][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] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
  [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]]==[/COLOR][COLOR= #DD0000]"POST"[/COLOR][COLOR= #007700]) {[/COLOR]
  [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$IPCheckQuery[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]) {[/COLOR] 
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<font color=red>Ow, you can only have 1 account.</font><br />"[/COLOR][COLOR= #007700];    
    }[/COLOR]
    [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]) <[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700]) {[/COLOR] 
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<font color=red>Your username must contain more than 3 characters.</font><br />"[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]) >[/COLOR] [COLOR= #0000BB]12[/COLOR][COLOR= #007700]) {[/COLOR] 
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<font color=red>Your username cant contain more than 12 characters.</font><br />"[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/preg_match"]preg_match[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]/^[a-z0-9]+$/i[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]) ) {[/COLOR] 
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<font color=red>Dont use wierd characters in your username.</font><br />"[/COLOR][COLOR= #007700];    
    }[/COLOR]
    [URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$UserCheckQuery[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]) {[/COLOR] 
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<font color=red>Ow, that username is already in use!</font><br />"[/COLOR][COLOR= #007700];    
    }[/COLOR]
    [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]])) {[/COLOR] 
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<font color=red>Please, fill in a email adress!</font><br />"[/COLOR][COLOR= #007700];        
    }[/COLOR]
    [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700](![/COLOR]filter_var[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]],[/COLOR] FILTER_VALIDATE_EMAIL[COLOR= #007700])) {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<font color=red>Your email adress is not correct!</font><br />"[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password2[/COLOR][COLOR= #007700]]) {[/COLOR] 
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<font color=red>The passwords doesnt match!</font><br />"[/COLOR][COLOR= #007700];    
    }[/COLOR]
    [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]]) <[/COLOR] [COLOR= #0000BB]4[/COLOR][COLOR= #007700]) {[/COLOR] 
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<font color=red>The password must contain more than 4 characters.</font><br />"[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
    [COLOR= #0000BB]$password[/COLOR][COLOR= #007700]=[/COLOR]hash[COLOR= #007700]([/COLOR]sha512[COLOR= #007700],[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]]);[/COLOR]
    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO user_users (username,password,email,IP,rang,banned) VALUES ("[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/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]$password[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]", "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]", 0, 0)"[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"success!"[/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]
    <form class="well" action="" method="POST">
    <input type="text" name="username" placeholder="Username.." /><br />
    <input type="text" name="email" placeholder="Email.." /><br />
    <input type="password" name="password" placeholder="Password.." /><br />
    <input type="password" name="password2" placeholder="Confirm password.." /><br />
    <button class="btn btn-info">Next..</button>
    </form>[/COLOR][COLOR= #007700];
    
    }[/COLOR]
    ?>
    
    <script src="http://code.jquery.com/jquery.js"></script>
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>


errors:
Notice: Undefined index: id in C:xampphtdocsbootstrapincconfig.php on line 12

Notice: Undefined index: id in C:xampphtdocsbootstrapregister.php on line 12

Notice: Undefined index: username in C:xampphtdocsbootstrapregister.php on line 13

Notice: Undefined index: email in C:xampphtdocsbootstrapregister.php on line 14
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Die variabelen hebben geen waarde op dit moment. Je moet ook controleren of je formulier verstuurd is....

if($_SERVER[REQUEST_METHOD]=="POST") {

Wat wil je met lijn 12 doen?
0
Berichten
6.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
Die variabelen hebben geen waarde op dit moment. Je moet ook controleren of je formulier verstuurd is....

if($_SERVER[REQUEST_METHOD]=="POST") {

Wat wil je met lijn 12 doen?
euhm.. bloos
Maar dit heb ik toch al?

if($_SERVER[REQUEST_METHOD]=="POST") {
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Niet op de goede plek. ... wink
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Volgens mij bestaat de sessie ook niet?
0
Berichten
4.912
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Beste Leden ,

Ik heb het volgende
tabel "forum_cat" :

Quote:
------
id |
------

tabel "forum_topics" :

Quote:
-------------
id | cat |
-------------

tabel "forum_reacties" :

Quote:
-------------------------
id | topic_id | time |
-------------------------

nu is het de bedoeling dat hij bij bijvoorbeeld categorie 2 de laatste reactie haalt uit het topics met de categorie 2

Iemand een idee hoe ik dit kan oplossen?
0
Berichten
5.274
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien

Eindhoven, Nederland

Iets van

SELECT forum_reacties.text FROM forum_reacties, forum_topics WHERE forum_topics.cat = 2 AND forum_reacties.topic_id = forum_topics.id ORDER BY forum_reacties.time DESC


Ben nu beetje slaperig, wss is die fout.
0
Lennard

Lid · Topicstarter

Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Ik zou de boel denormaliseren en cat_id ook in je reactietabel zetten. Is niet zoals het officieel hoort maar scheelt wel in snelheid.
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Als je gaat normaliseren waarom niet gelijk bij een bericht plaatsen een update query in de forum_cat?

Bij bericht plaatsen/aanpassen en topic plaatsen vind ik dat er best een extra query gedraaid mag worden.
0
Lennard

Lid · Topicstarter

Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Rogier schreef:
Als je gaat normaliseren waarom niet gelijk bij een bericht plaatsen een update query in de forum_cat?
Bij bericht plaatsen/aanpassen en topic plaatsen vind ik dat er best een extra query gedraaid mag worden.
Ooh met een last_post_id ofzo, dat is nog handiger inderdaad als je dit doel wil bereiken.
0
Berichten
1.579
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lennard schreef:
Eerdere citaten tonen
Rogier schreef:
Als je gaat normaliseren waarom niet gelijk bij een bericht plaatsen een update query in de forum_cat?
Bij bericht plaatsen/aanpassen en topic plaatsen vind ik dat er best een extra query gedraaid mag worden.
Ooh met een last_post_id ofzo, dat is nog handiger inderdaad als je dit doel wil bereiken.
je kan toch ook aan topic tijd mee geven waarneer laadt gereageerd in is ?
0
Lennard

Lid · Topicstarter

Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Ja, maar als je ooit veel topics hebt dan moet je per categorie alle topics sorteren op laatste reactiedatum, en dat duurt veel langer dan even de last_post_id ophalen en daarmee het topic opzoeken.
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lennard schreef:
neeee dat moet je gewoon niet willen
Ik wil het ook niet in mijn eigen code maar als je de naam van je kolom niet wil veranderen dan is dit een optie
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