Php vraagje

Gestart doorMitchels41 reacties155 weergaven

42 berichten · pagina 1 van 3

Mitchels

Lid · Topicstarter

Berichten
2.396
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]../_include.php[/COLOR][COLOR= #007700]);[/COLOR]
design_boven[COLOR= #007700]([/COLOR][COLOR= #DD0000]Home[/COLOR][COLOR= #007700]);[/COLOR]
check_login[COLOR= #007700]();[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<h2>Uitbetalen</h2>[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT * FROM `users` WHERE `user`="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$row1[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row1[/COLOR][COLOR= #007700])){[/COLOR]

[COLOR= #0000BB]$aantalcredits[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"kliks"[/COLOR][COLOR= #007700]];[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$aantalcredits[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]2000[/COLOR][COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je moet minimaal 0,5 euro/2000punten hebben verdiend voor je een uitbetaling kan aanvragen."[/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]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]])){[/COLOR]

[COLOR= #0000BB]$user[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$email[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$in[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]in[/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]
[COLOR= #0000BB]$aantal[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]aantal[/COLOR][COLOR= #007700]];[/COLOR]

[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"INSERT INTO uitbetalen (`user`, `email`, `in`, `naam`, `aantal`) VALUES 
($user,$email,$in,$naam,$aantal)"[/COLOR][COLOR= #007700];[/COLOR]

 [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/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]"Je uitbetaling word zo snel mogenlijk behandeld!"[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
?>

<table width="75%">
<form action="" method="POST">
<tr><td>Username:</td></tr>
<tr><td><input type="text" name="user" value="[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]];[/COLOR] ?>"readonly ></td></tr>
<tr><td>Email:</td></tr>
<tr><td><input type="text" name="email" value="[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]];[/COLOR] ?>" readonly></td></tr>
<tr><td>Uitbetalen in: <font size="1"></font></td></tr>
<tr><td><select size=1  name="in">
<option selected value=none>Kies er een uit</option>
    <option value=Paypal>Paypal</option>
    <option value=Dutchleader>Dutchleader credits</option>
    <option value=Erohits>Erohits credits</option>
    <option value=Annepromo>Annepromo credits</option>
    <option value=Magichits>Magichits credits</option>
    <option value=PromotieKingdom>PromotieKingdom credits</option>
    <option value=Powerhits>Powerhits credits</option>
    <option value=kliks>Kliks op je site</option>
    <option value=One2xs>One2xs</option>
    </select></td>
</tr>
<tr><td>Uitbetaal naam*</td></tr>
<tr><td><input type="text" name="naam" value=""></td></tr>
<tr><td>Aantal credits:</td></tr>
<tr><td><input type="text" name="aantal" value="[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]kliks[/COLOR][COLOR= #007700]];[/COLOR] ?>"></td></tr>
<tr><td><input type="submit" name="submit" value="Verzenden"></td></tr>
</form>
</table>
<br /><br />
* = Url als je kliks kiest anders het account naam waar je je wil laten uitbetalen.
[COLOR= #0000BB]<?php[/COLOR]
        [COLOR= #007700]}
    }
}[/COLOR]
?>     
[COLOR= #0000BB]<?[/COLOR]
design_onder[COLOR= #007700]([/COLOR][COLOR= #DD0000]1[/COLOR][COLOR= #007700]);[/COLOR]
?>


Ik heb deze code
Nu wil ik dat er als je al een uitbetaling hebt aangevraagd, en dus je username in de db staat bij uitbetalen dat je dan een mededeling krijgt van Je hebt al een uitbetaling aangevraagd. Ik loopt nu al de hele middag te kloten, maar het lukt niet.
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Als $_SESSION[user] de gebruiker is:
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include_once"]include_once[/URL] [COLOR= #DD0000]../_include.php[/COLOR][COLOR= #007700];[/COLOR]
design_boven[COLOR= #007700]([/COLOR][COLOR= #DD0000]Home[/COLOR][COLOR= #007700]);[/COLOR]
check_login[COLOR= #007700]();[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<h2>Uitbetalen</h2>[/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 1 FROM uitbetalen WHERE user = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/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/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$check[/COLOR][COLOR= #007700]) !==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt al een uitbetaling open staan.[/COLOR][COLOR= #007700];
    
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]

    [COLOR= #0000BB]$row1[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT kliks, user, email FROM users WHERE user = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
    
    [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row1[/COLOR][COLOR= #007700]))
    {[/COLOR]
        
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]kliks[/COLOR][COLOR= #007700]] <[/COLOR] [COLOR= #0000BB]2000[/COLOR][COLOR= #007700])
        {[/COLOR]
            
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je moet minimaal 0,5 euro/2000punten hebben verdiend voor je een uitbetaling kan aanvragen.[/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][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/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"
                                INSERT INTO
                                    uitbetalen
                                (
                                    user,
                                    email,
                                    `in`,
                                    naam,
                                    aantal
                                )
                                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]user[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]",
                                    "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/strtolower"]strtolower[/URL][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][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]in[/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]naam[/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]aantal[/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]Je uitbetaling word zo snel mogenlijk behandeld![/COLOR][COLOR= #007700];
            
            }[/COLOR]
            [URL="http://www.php.net/else"]else[/URL]
            [COLOR= #007700]{[/COLOR]
                ?>
                <form action="" method="POST">
                    <table width="75%">
                        <tr>
                            <td>
                                Username:
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input type="text" name="user" value="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]];[/COLOR] ?>" readonly="readonly" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Email:
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input type="text" name="email" value="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]];[/COLOR] ?>" readonly="readonly" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Uitbetalen in:
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <select size="1" name="in">
                                    <option selected="selected" value="none">Kies er een uit</option>
                                    <option value="Paypal">Paypal</option>
                                    <option value="Dutchleader">Dutchleader credits</option>
                                    <option value="Erohits">Erohits credits</option>
                                    <option value="Annepromo">Annepromo credits</option>
                                    <option value="Magichits">Magichits credits</option>
                                    <option value="PromotieKingdom">PromotieKingdom credits</option>
                                    <option value="Powerhits">Powerhits credits</option>
                                    <option value="kliks">Kliks op je site</option>
                                    <option value="One2xs">One2xs</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Uitbetaal naam*
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input type="text" name="naam" value="" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Aantal credits:
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input type="text" name="aantal" value="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]kliks[/COLOR][COLOR= #007700]];[/COLOR] ?>" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input type="submit" name="submit" value="Verzenden">
                            </td>
                        </tr>
                    </table>
                </form>
                <br /><br />
                * = Url als je kliks kiest anders het account naam waar je je wil laten uitbetalen.
                [COLOR= #0000BB]<?php[/COLOR]
                
            [COLOR= #007700]}
            
        }
        
    }

}[/COLOR]

design_onder[COLOR= #007700]([/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]);[/COLOR]
?>


Ik zou het script nog wel een stuk beter beveiligen / controles inbouwen.
0
Mitchels

Lid · Topicstarter

Berichten
2.396
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dankje, wat is er dan nog fout, hij werkt perfect in iedergevalyummieIn het begin kon je elke gewenste gebruikersnaam invullen en kon je met ej eigen paypal adres op iemand anders zijn naam een uitbetaling aanvragen emo Dat is verholpen, ik weet dat je een onbeperkt aantal credits kan laten uitbetalen, dat controleert hij niet. Dat ga ik zo maken. Wat is nog meer slecht?
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Niet echt slecht, maar wel slordig:
- Je kunt een uitbetaling in koeien aanvragen, terwijl die niet in dat rijtje staan; je site controleert niet of $_POST[in] wel in dat rijtje staat
- Je controleert niet of het emailadres geldig is
en je controleert niet of de username enzo is ingevuld.

Haal alles wat je in een database stopt sowieso door mysql_real_escape_string(); dan is het in ieder geval al veiliger dan zonder.
0
Mitchels

Lid · Topicstarter

Berichten
2.396
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
$_POST[in] weet ik ookwinkEmail adres wordt gehaald uit de db.
Dus hetzelfde als bij je aanmelding en die is bij je aanmelding bevestigdwinkUsername wordt automatisch ingevuld door $_SESSION[user]
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Nee, op regel 48, 49 en 50 stop je de data die in het formulier is ingevuld in je database.
0
Mitchels

Lid · Topicstarter

Berichten
2.396
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nee hoor,
Probeer maar: http://kliklinks.nl/leden/uitbetalen1.php
Vul maar wat onzin in bij uitbetaal naam, dan vertel ik je wat je hebt ingevoerd
0
Berichten
1.926
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hij is zo toch goed=
email en naam word automatisch ingevoerd!

Het enigste wat fout kan is je naam op de uitbetaal site!
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Ik heb uitbetalen in lalalaaaaaaaaaa gedaan, mn username aangepast en mn emailadres. En hoe heb je ze in de database staan nu? biggrin
0
Mitchels

Lid · Topicstarter

Berichten
2.396
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
WTF
Kut CHROME & IE!emoHier kan dat niet,
user email in naam aantal
lennard =D fout emailadres hierzo lalalaaaaaaaaaa 1
Hoe is dat nou optelossenconfused
0
Erik

Lid

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
if(!filter_var($_POST[email], FILTER_VALIDATE_EMAIL))
{
echo goed;
}
else
{
echo fout;
}
0
Berichten
1.160
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR]filter_var[COLOR= #007700]([/COLOR][COLOR= #DD0000]"someone@example....com"[/COLOR][COLOR= #007700],[/COLOR] FILTER_VALIDATE_EMAIL[COLOR= #007700]))
 {[/COLOR]
 [URL="http://www.php.net/echo"]echo[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"E-mail is not valid"[/COLOR][COLOR= #007700]);
 }[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
 [COLOR= #007700]{[/COLOR]
 [URL="http://www.php.net/echo"]echo[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"E-mail is valid"[/COLOR][COLOR= #007700]);
 }[/COLOR]
?>


Bron:http://www.w3schools.com/PHP/func_filter_var.asp
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Mitchels schreef:
WTF
Kut CHROME & IE!emoHier kan dat niet,
user email in naam aantal
lennard =D fout emailadres hierzo lalalaaaaaaaaaa 1
Hoe is dat nou optelossenconfusedHaha. emo hypocrite
Door niet $_POST[user] maar $_SESSION[user] te gebruiken, en door de input te valideren.
0
Mitchels

Lid · Topicstarter

Berichten
2.396
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Of jij loopt mij te treiteren op 1 april redfaceDoor het in de db te veranderen xd
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Nee. emoMet Opera kun je de HTML aanpassen, dus aanpassen + verzenden en t staat fout in jouw database..
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