Code controleren

Gestart doorDesire13 reacties103 weergaven

14 berichten · pagina 1 van 1

Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo,

Ik ben bezig met een beta code systeem.

Alleen ik heb het admin paneel nu helemaal klaar. Nu alleen de index pagina nog waar hij de code moet controleren en als hij goed is dan moet hij worden doorgestuurt naar een pagina.

Dit heb ik nu, allen ik kom niet verder.

Iemand die me kan helpen?

[COLOR= #0000BB]<?php[/COLOR]
    [URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]config.php[/COLOR][COLOR= #007700];[/COLOR]
?>
<html>
<head>
<title> [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]"$site_naam"[/COLOR][COLOR= #007700];[/COLOR] ?> </title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>

[COLOR= #0000BB]<?php[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div id="logo_tekst">[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"$site_naam"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</div>[/COLOR][COLOR= #007700];[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div id="menu">[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<a href="index.php"><active>Home</active></a> - [/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<a href="indexa.php">Admin</a>[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</div>[/COLOR][COLOR= #007700];[/COLOR]
?>
[COLOR= #0000BB]<?php[/COLOR]
        
?>
<div id="content">
[COLOR= #0000BB]<?php[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<center>[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<form action="index.php" method="post">
            <input type="text" name="code" /><br />
            <input type="submit" name="submit" value="Beta code!" /><br />
            </form>[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</center>[/COLOR][COLOR= #007700];[/COLOR]
?>
</div>

</body>
</html>


Als iemand het lukt, krijgt degene 0.3 punten.

Mvg,
Desire
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Waarom

echo"$site_naam";


als je ook gewoon

echo $site_naam;


kan doen.

@wouter dat werkt dus voor geen meter hè.
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Rik schreef:
Waarom
echo"$site_naam";


als je ook gewoon

echo $site_naam;


kan doen.

@wouter dat werkt dus voor geen meter hè.

Ik weet niet, ik heb het zo geleerd.
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Leer dat dan maar snel opnieuw emo
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Rik schreef:
Leer dat dan maar snel opnieuw emo
Ja maar daar gaat dit topic niet over wink
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Brakke code krijgt brakke hulp.

Anyway. Iets in de trant van dit zou moeten werken:

[COLOR= #0000BB]<?php[/COLOR]

    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REUQEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700])
    {[/COLOR]
        
        [COLOR= #0000BB]$sQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT 1 FROM tabel WHERE code = "[/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]code[/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/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sQuery[/COLOR][COLOR= #007700]) !=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])[/COLOR]
            [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Location: delinknaarjesite.nl/beta.php[/COLOR][COLOR= #007700]);[/COLOR]    
        [URL="http://www.php.net/else"]else[/URL]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Dit is geen correcte beta code[/COLOR][COLOR= #007700];
        
    }[/COLOR]

?>
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Rik schreef:
Brakke code krijgt brakke hulp.

Anyway. Iets in de trant van dit zou moeten werken:

[COLOR= #0000BB]<?php[/COLOR]

    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REUQEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700])
    {[/COLOR]
        
        [COLOR= #0000BB]$sQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT 1 FROM tabel WHERE code = "[/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]code[/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/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sQuery[/COLOR][COLOR= #007700]) !=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])[/COLOR]
            [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Location: delinknaarjesite.nl/beta.php[/COLOR][COLOR= #007700]);[/COLOR]    
        [URL="http://www.php.net/else"]else[/URL]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Dit is geen correcte beta code[/COLOR][COLOR= #007700];
        
    }[/COLOR]

?>
Hij geeft deze error aan
Notice: Undefined index: REUQEST_METHOD in D:xampphtdocsindex.php on line 23
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Moet REQUEST zijn ipv REUQUEST
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Thommiee schreef:
Moet REQUEST zijn ipv REUQUEST
TY Hij werkt.

toevoeging op 1 maart 2012, 18:55:42:
Alleen als ik nu die code invoer dan gaat hij naar beta.php, alleen hoe laat ik de beta.php nu alleen zien als de beta code correct is?confused
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Sessie / cookie aanmaken met speciaal gegenereerde code / beta code en kijken op de beta.php of die code correct is yummie
0
Desire

Lid · Topicstarter

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nielsie schreef:
Sessie / cookie aanmaken met speciaal gegenereerde code / beta code en kijken op de beta.php of die code correct is yummie
Oke bedankt.

toevoeging op 1 maart 2012, 20:30:51:
Nieuwe fout:

Warning: Cannot modify header information - headers already sent by (output started at /home/design/domains/design.s3.one2xs.com/public_html/beta/index.php:6) in /home/design/domains/design.s3.one2xs.com/public_html/beta/index.php on line 30
Dit is geen correcte beta code


Bij deze code:
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
    [URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]config.php[/COLOR][COLOR= #007700];[/COLOR]
?>
<html>
<head>
<title> [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]"$site_naam"[/COLOR][COLOR= #007700];[/COLOR] ?> </title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>

[COLOR= #0000BB]<?php[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div id="logo_tekst">[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"$site_naam"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</div>[/COLOR][COLOR= #007700];[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div id="menu">[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<a href="index.php"><active>Home</active></a> - [/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<a href="indexa.php">Admin</a>[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</div>[/COLOR][COLOR= #007700];[/COLOR]
?>

<div id="content">
[COLOR= #0000BB]<?php[/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]
        
        [COLOR= #0000BB]$sQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT code FROM beta_code WHERE code = "[/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]code[/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/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sQuery[/COLOR][COLOR= #007700]) !=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])[/COLOR]
            [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Location: beta.php[/COLOR][COLOR= #007700]);[/COLOR]    
        [URL="http://www.php.net/else"]else[/URL]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<center>[/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Dit is geen correcte beta code[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</center>[/COLOR][COLOR= #007700];
        
    }[/COLOR]
    
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<center>[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<form action="index.php" method="post">
            <input type="text" name="code" /><br />
            <input type="submit" name="submit" value="Beta code!" /><br />
            </form>[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</center>[/COLOR][COLOR= #007700];[/COLOR]
?>
</div>

</body>
</html>
0
Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Desire schreef:
Eerdere citaten tonen
Nielsie schreef:
Sessie / cookie aanmaken met speciaal gegenereerde code / beta code en kijken op de beta.php of die code correct is yummie
Oke bedankt.

toevoeging op 1 maart 2012, 20:30:51:
Nieuwe fout:

Warning: Cannot modify header information - headers already sent by (output started at /home/design/domains/design.s3.one2xs.com/public_html/beta/index.php:6) in /home/design/domains/design.s3.one2xs.com/public_html/beta/index.php on line 30
Dit is geen correcte beta code


Bij deze code:
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
    [URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]config.php[/COLOR][COLOR= #007700];[/COLOR]
?>
<html>
<head>
<title> [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]"$site_naam"[/COLOR][COLOR= #007700];[/COLOR] ?> </title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>

[COLOR= #0000BB]<?php[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div id="logo_tekst">[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"$site_naam"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</div>[/COLOR][COLOR= #007700];[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div id="menu">[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<a href="index.php"><active>Home</active></a> - [/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<a href="indexa.php">Admin</a>[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</div>[/COLOR][COLOR= #007700];[/COLOR]
?>

<div id="content">
[COLOR= #0000BB]<?php[/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]
        
        [COLOR= #0000BB]$sQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT code FROM beta_code WHERE code = "[/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]code[/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/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sQuery[/COLOR][COLOR= #007700]) !=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])[/COLOR]
            [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Location: beta.php[/COLOR][COLOR= #007700]);[/COLOR]    
        [URL="http://www.php.net/else"]else[/URL]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<center>[/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Dit is geen correcte beta code[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</center>[/COLOR][COLOR= #007700];
        
    }[/COLOR]
    
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<center>[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<form action="index.php" method="post">
            <input type="text" name="code" /><br />
            <input type="submit" name="submit" value="Beta code!" /><br />
            </form>[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</center>[/COLOR][COLOR= #007700];[/COLOR]
?>
</div>

</body>
</html>
Gebruik sessies zoals nielsie eerder nog zei.

En de if functie enz afsluiten met een } en starten met een { confused
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
@ vriendje:

if ( $var == var )
    echo  var is gelijk aan var ;


is gewoon exact hetzelfde als

if ( $var == var ) {
    echo  var is gelijk aan var ;
}


Maar als je meerdere regels gaat gebruiken achter de if ( .. ) dan moet je pas accolades gaan gebruiken.

De fout waar hij mee komt heeft verder niks met sessies te maken. Het komt gewoon omdat hij al eerder headers heeft verzonden (HTML output) waardoor je niet nogmaals headers kan verzenden (met de header() functie). Je kunt hiervoor ob_start(); bovenaan zetten, maar dat is niet echt een geweldige oplossing, en ob_start kan later voor problemen zorgen.
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