Naam automatisch invoeren

Gestart doorJoeri9 reacties36 weergaven

10 berichten · pagina 1 van 1

Joeri

Lid · Topicstarter

Berichten
5.737
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb een berichtenbalk en een inlogsysteem
nu wil ik ze graag aan elkaar koppelen
ik wil dat je boven hetsysteem van de berichtenbalk niet je naam meer in hoeft te vullen maar staat :

Je bent ingelogd als [naam]

Hoe kan ik dat het beste aanpakken?
0
Berichten
2.396
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
$_SESSION[user] ?
0
Krm

Lid

Berichten
6.235
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
het script van phpmenno nakken
0
Joeri

Lid · Topicstarter

Berichten
5.737
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Al geprobeerd van mitchels maar ik heb een script waar dat (vind ik) niet makkelijk bij gaat

[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]login_hash[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]userid[/COLOR][COLOR= #007700]])) {[/COLOR]
        [COLOR= #0000BB]$check[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT userid FROM login_sessions WHERE ip = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]" AND hash = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]login_hash[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" ORDER BY log_time DESC"[/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][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$check[/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]bericht[/COLOR][COLOR= #007700]])) {[/COLOR] 
            [COLOR= #0000BB]$bericht[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/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]naam[/COLOR][COLOR= #007700]])) {[/COLOR] 
            [COLOR= #0000BB]$naam[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]; 
          }[/COLOR] 
        ?>  

          <form method="POST"> 
              <input type="hidden" name="woot" value="1"> 
              <strong>Naam</strong> <br /> 
              <input type="text" name="naam" maxlength="15" value="[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$naam[/COLOR][COLOR= #007700];[/COLOR] ?>"> <br /><br /> 
                
              <strong>Bericht</strong><br /> 
              <textarea id="bericht" name="bericht" rows="5" cols="33" style="overflow:hidden">[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$bericht[/COLOR][COLOR= #007700];[/COLOR] ?></textarea><br /> 
              <i>Het bericht mag maar 100 tekens groot zijn</i><br /><br /> 
              <input type="Submit" value="Plaats"> 
          </form> 
          <br /><strong>Emoticons</strong><br /> 
          <a href="#" onclick="insertBBCode(bericht, [bomb]);"><img src="images/emoticons/bomb.png" width="16" height="16" alt="Bomb" /></a> 
          <a href="#" onclick="insertBBCode(bericht, [cake]);"><img src="images/emoticons/cake.png" width="16" height="16" alt="Cake" /></a> 
          <a href="#" onclick="insertBBCode(bericht, [nl]);"><img src="images/emoticons/nl.gif" width="16" height="16" alt="Nederland" /></a> 
          <a href="#" onclick="insertBBCode(bericht, [fr]);"><img src="images/emoticons/fr.gif" width="16" height="16" alt="Frankrijk" /></a> 
          <a href="#" onclick="insertBBCode(bericht, [de]);"><img src="images/emoticons/de.gif" width="16" height="16" alt="Duitsland" /></a> 
          <a href="#" onclick="insertBBCode(bericht, [us]);"><img src="images/emoticons/us.gif" width="16" height="16" alt="USA" /></a> 
          <a href="#" onclick="insertBBCode(bericht, [larrow]);"><img src="images/emoticons/arrow_left.gif" width="16" height="16" alt="Arrow left" /></a> 
          <a href="#" onclick="insertBBCode(bericht, [rarrow]);"><img src="images/emoticons/arrow_right.gif" width="16" height="16" alt="Arrow right" /></a><br /> 
          <br /> 
                [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]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]woot[/COLOR][COLOR= #007700]])) {[/COLOR] 
                      [COLOR= #0000BB]$naam[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strtolower"]strtolower[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]));[/COLOR]  
                      [COLOR= #0000BB]$bericht[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]];[/COLOR] 
                   
                      [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bericht[/COLOR][COLOR= #007700]) >[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700]) {[/COLOR] 
                            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<center>Je bericht is te groot: [/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bericht[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000] van de 100 tekens</center>[/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]$naam[/COLOR][COLOR= #007700])) {[/COLOR] 
                        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<center>Je hebt geen naam ingevuld.</center>[/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]$bericht[/COLOR][COLOR= #007700])) {[/COLOR] 
                        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<center>Je hebt geen bericht ingevuld.</center>[/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]$naam[/COLOR][COLOR= #007700]) >[/COLOR] [COLOR= #0000BB]15[/COLOR][COLOR= #007700]) {[/COLOR] 
                        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<center>Je naam heeft meer dan 15 tekens</center>[/COLOR][COLOR= #007700];     
                      }[/COLOR] 
                      [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]last_session_request[/COLOR][COLOR= #007700]] >[/COLOR] [URL="http://www.php.net/time"]time[/URL][COLOR= #007700]() -[/COLOR] [COLOR= #0000BB]10[/COLOR][COLOR= #007700]){[/COLOR] 
                        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<center>Je kan maar eens in de 10 seconden een bericht posten</center>[/COLOR][COLOR= #007700]; 
                      }[/COLOR] 
                      [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR] 
                        [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO talkbalk (naam, bericht, ip) VALUES ("[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_escape_string"]mysql_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$naam[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]", "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_escape_string"]mysql_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bericht[/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]")"[/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/echo"]echo[/URL] [COLOR= #DD0000]"<center><strong><font color=red>Je bericht is geplaatst!</font></strong></center>"[/COLOR][COLOR= #007700];[/COLOR] 
                        [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]last_session_request[/COLOR][COLOR= #007700]] =[/COLOR] [URL="http://www.php.net/time"]time[/URL][COLOR= #007700](); 
                      }                                                                                                
                  } 



               
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div class="multierror">Aleen ingelogde personen mogen deze pagina zien</div>[/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]<div class="multierror">Aleen ingelogde personen mogen deze pagina zien</div>[/COLOR][COLOR= #007700];
    }[/COLOR]

 ?>
0
Berichten
2.396
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
$naam = $_SESSION[user];
0
Joeri

Lid · Topicstarter

Berichten
5.737
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Waar zou ik dat neer moeten zetten?
Het lijkt dat ik lui ben nu maar ik heb het op aantal plekken geprobeerd
Ik weet dat omdat ik dit niet kan vinden noob ben maar ik ben bezig met cursussen
en wil wel zsm bezoekers wie het hele script maakt met dat automatische naam erin krijgt 0,05
0
Berichten
2.396
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wordt de berichtenbalk alleen gebruikt door leden?
0
Joeri

Lid · Topicstarter

Berichten
5.737
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja sindskort, hij staat nu dus alleen op de ledenpagina
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Uh, je moet dat dan ff in een sql maken dat hij de naam opvraagd op basis van het id, en die vervolgens gebruiken yummieIk kan strax, morgen, of aan het eindvan de week kijken yummie
0
Berichten
1.160
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]function[/COLOR] getUsername[COLOR= #007700]([/COLOR][COLOR= #0000BB]$id[/COLOR][COLOR= #007700])
{[/COLOR]
    [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/sprintf"]sprintf[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT user FROM users WHERE id=%s"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$id[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]));[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700])
    {[/COLOR]
        [COLOR= #0000BB]$data[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]));[/COLOR]
        [URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$data[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]];
    }
}[/COLOR]
?>
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