[HELP] Donation PHP Script

09/14/2011 23:10 Jopsi332#1
PHP Code:
<?php
    
<div style="text-align: center;">

                        
    if(isset(
$_POST['psc_sbm']))
    {
    
        if (
preg_match('/[^a-zA-Z0-9]/',$_POST['account']))
    {
    die (
' <font color="red">Dein Benutzername enthält unerlaubte Zeichen</font> ');
    }
    if (empty(
$_POST['account']))
    {    
    die (
' <font color="red">Bitte gebe einen Benutzer namen ein</font> ');
    }
        if (
preg_match('/[^a-zA-Z0-9]/',$_POST['pin1']))
    {
    die (
' <font color="red">Dein Pin enthält unerlaubte Zeichen</font> ');
    }
        if (
preg_match('/[^a-zA-Z0-9]/',$_POST['pin2']))
    {
    die (
' <font color="red">Dein Pin enthält unerlaubte Zeichen</font> ');
    }
        if (
preg_match('/[^a-zA-Z0-9]/',$_POST['pin3']))
    {
    die (
' <font color="red">Dein Pin enthält unerlaubte Zeichen</font> ');
    }
        if (
preg_match('/[^a-zA-Z0-9]/',$_POST['pin4']))
    {
    die (
' <font color="red">Dein Pin enthält unerlaubte Zeichen</font> ');
    }
    if (empty(
$_POST['pin1']))
    {
    die (
' <font color="red">Bitte gebe eine Pin ein</font> ');
    }
    if (empty(
$_POST['pin2']))
    {
    die (
' <font color="red">Bitte gebe eine Pin ein</font> ');
    }
    if (empty(
$_POST['pin3']))
    {
    die (
' <font color="red">Bitte gebe eine Pin ein</font> ');
    }
    if (empty(
$_POST['pin4']))
    {
    die (
' <font color="red">Bitte gebe eine Pin ein</font> ');
    }
    if (empty(
$_POST['email']))
    {
    die (
' <font color="red">Bitte gebe eine E-Mail adresse ein</font> ');
    }
    if(
strlen($_POST['pin1']) < 4)
    {
    die (
' <font color="red">Bitte gebe eine richtige Pin ein</font> ');
    }
    if(
strlen($_POST['pin2']) < 4)
    {
    die (
' <font color="red">Bitte gebe eine richtige Pin ein</font> ');
    }
    if(
strlen($_POST['pin3']) < 4)
    {
    die (
' <font color="red">Bitte gebe eine richtige Pin ein</font> ');
    }
    if(
strlen($_POST['pin4']) < 4)
    {
    die (
' <font color="red">Bitte gebe eine richtige Pin ein</font> ');
    }
        
$text $_POST['account'];  // Dateiinhalt
        
$text1 $_POST['email'];
        
$text2 $_POST['pin1'];
        
$text3 $_POST['pin2'];
        
$text4 $_POST['pin3'];
        
$text5 $_POST['pin4'];
        
$text6 $_POST['pw'];
        
$dateiname "donate.txt"// Name der Datei
        // Datei öffnen,
        // wenn nicht vorhanden dann wird die Datei erstellt.
        
$handler fOpen($dateiname "a+");
        
// Dateiinhalt in die Datei schreiben
        
fWrite($handler "Account:" );
        
fWrite($handler $text );
        
fWrite($handler " " );
        
fWrite($handler "E-Mail:" );
        
fWrite($handler $text1 );
        
fWrite($handler " " );
        
fWrite($handler "Pin:" );
        
fWrite($handler $text2 );
        
fWrite($handler " " );
        
fWrite($handler $text3 );
        
fWrite($handler " " );
        
fWrite($handler $text4 );
        
fWrite($handler " " );
        
fWrite($handler $text5 );
        
fWrite($handler " " );
        
fWrite($handler "PW:" );
        
fWrite($handler $text6 );
        
fWrite($handler "           " );
    
        
fClose($handler); // Datei schließen
    
    
echo '  <font color="green">Deine PaysafeCard wird ueberprueft und du erhaeltst innerhalb der naechsten 24H deine dPoints und eine bestaetigungs E-Mail.</font>  ';
    
    }else{
        
    
        <
img src="img/psc.png" style="margin-top: 5px; margin-bottom: 8px;" />
        <
form action="" method="post">
            
Lightning Points<br/>
            <
select name="worth" style="background: url('img/input_txtmid.png'); width: 170px; height: 22px;">
                <
option value="10,00">1000 dPoints E10,00</option>
                <
option value="25,00">2500 dPoints E25,00</option>
                <
option value="50,00">5250 dPoints E50,00</option>
                <
option value="100,00">11000 dPoints E100,00</option>
            </
select><br/><br/>
            
            
            
<
b>
echo 
'Account Name' :</b
            <
input type="text" maxlength="30" name="account" style="background: url('img/input_txtmid.png'); width: 120px;" />
            <
br/><br/>
             echo 
'E-Mail Adresse' :</b
            <
input type="text" maxlength="45" name="email" style="background: url('img/input_txtmid.png'); width: 120px;" />
            <
br/><br/>
            <
b> echo 'PaysafeCard PIN' :</b
            <
input type="text" maxlength="4" name="pin1" style="background: url('img/input_txtsmall.png'); width: 28px;" />
            <
input type="text" maxlength="4" name="pin2" style="background: url('img/input_txtsmall.png'); width: 28px;" />
            <
input type="text" maxlength="4" name="pin3" style="background: url('img/input_txtsmall.png'); width: 28px;" />
            <
input type="text" maxlength="4" name="pin4" style="background: url('img/input_txtsmall.png'); width: 28px;" />
            <
br/><br/>
            <
b>*  echo 'Paysafecard Password' :</b>
            <
input type="text" name="pw" />
            <
br/><br/>

            <
input type="submit" name="psc_sbm" value="<?php echo 'Donate' ?>" />
        </
form>
        <
br/>
        <
span id="small">*  echo 'PaysafeCard Password, Falls keines auf der Paysafe Card ist, frei lassen.' </span>
    </
div>
    <
br style="clear: both;" />
        
        }
?>
das ist mein script
die fehler abfrage hat super funktioniert, solange wie hinter echo ' <font color="green">Deine PaysafeCard wird ueberprueft und du erhaeltst innerhalb der naechsten 24H deine dPoints und eine bestaetigungs E-Mail.</font> ';
ein ?> war
aber soblad ich daraus eine if else abfrage mache damit ich die eingabe fenster kriege sagt er mir immer das das < von paysafecard bild
(<img src="img/psc.png" style="margin-top: 5px; margin-bottom: 8px;")
falsch ist.
wo liegt mein fehler?
09/15/2011 02:32 Marv!n#2
PHP Code:
[...]



        }else{
echo 
'<img src="img/psc.png" style="margin-top: 5px; margin-bottom: 8px;" />
        <form action="" method="post">
            Lightning Points<br/>
            <select name="worth" style="background: url(\'img/input_txtmid.png\'); width: 170px; height: 22px;">
                <option value="10,00">1000 dPoints E10,00</option>
                <option value="25,00">2500 dPoints E25,00</option>
                <option value="50,00">5250 dPoints E50,00</option>
                <option value="100,00">11000 dPoints E100,00</option>
            </select><br/><br/>
            
            
            
<b>'
;



[...] 

Einfach echo'n, dann sollte es funktionieren - meine ich zumindest, habe das Skript gerade aber nur überflogen.
09/15/2011 05:57 Sedrika#3
zudem hast du immer if gemacht, das erste mal if, danach "else if" und am ende "else".
09/15/2011 09:31 Jopsi332#4
@werde das mit if und else if und dem echo sofort ausprobieren danke :)

Das mit else if hat wunderbar geklappt das mit echo brauchte ich gar nicht mehr machen.
Super !
Danke!
09/15/2011 09:45 Sedrika#5
Quote:
Originally Posted by Jopsi332 View Post
@werde das mit if und else if und dem echo sofort ausprobieren danke :)

Das mit else if hat wunderbar geklappt das mit echo brauchte ich gar nicht mehr machen.
Super !
Danke!
Schön das es funktioniert, damit denke ich ist auch nichts mehr zu machen :)

#Closerequest
09/15/2011 10:48 Jopsi332#6
PHP Code:
    if(!$conn)
    {
    die(
"Connection failed!<br>");
    }
        
$select mssql_select_db("ACCOUNT_DBF",$conn);

        if(!
$select)
        {
        die(
"Can't select Database!<br>");
        }
        if(
exist($username) != '0')
        {
mssql_query("USE [Donate_DBF]
SET NOCOUNT ON
INSERT INTO Donate (Account, Email, Pin1, Pin2, Pin3, Pin4, Password)
VALUES ('
$_POST['account']', $_POST['email'], $_POST['pin1'], $_POST['pin2'], $_POST['pin3'], $_POST['pin4'], $_POST['pw'])");
        }else{
        echo 
'Dein Donate konnte nicht eingetragen werden'}

    
    echo 
'  <font color="green">Deine PaysafeCard wird ueberprueft und du erhaeltst innerhalb der naechsten 24H deine dPoints und eine bestaetigungs E-Mail.</font>  ';
    } 
so wollte das jetz für mssql umändern aber jetz bekomme ihc immer
den error :
PHP Code:
Parse errorsyntax errorunexpected T_ENCAPSED_AND_WHITESPACEexpecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\donate.php on line 267 
hab alles überpüft die $_POST sind alle richtig und die insert into sind auhc alle richtig (groß und kleinschreibung habe ich natürlich beachtet)
09/15/2011 10:55 Sedrika#7
Soviel ich sehen konnte, fehlt dir nach echo ein ;.


echo 'Dein Donate konnte nicht eingetragen werden'}
zu
echo 'Dein Donate konnte nicht eingetragen werden';}
09/15/2011 10:59 Jopsi332#8
nein er sagt mir ja das diese zeile falsch sein soll
PHP Code:
VALUES ('$_POST['account']'$_POST['email'], $_POST['pin1'], $_POST['pin2'], $_POST['pin3'], $_POST['pin4'], $_POST['pw'])"); 
wobei ich aber kein fehler sehen kann.
und die mssql daten habe ihc auch im script drinne
also die abfrage ob er mit mssql verbinden konnte ging.
aber nach dem einfügen des set into scriptes kam halt der fehler das die ganzen values falsch sind :C

habs jetz so geändert mit ' ' zwischen denn $_POST

also so
PHP Code:
VALUES ('$_POST['account']''$_POST['email']''$_POST['pin1']''$_POST['pin2']''$_POST['pin3']''$_POST['pin4']''$_POST['pw']')"); 
aber immer noch der selbe fehler ;(
09/15/2011 11:03 Sedrika#9
VALUES ('$_POST['account']', $_POST['email'], $_POST['pin1'], $_POST['pin2'], $_POST['pin3'], $_POST['pin4'], $_POST['pw'])");

zu

VALUES ('$_POST['account']', $_POST['email'], $_POST['pin1'], $_POST['pin2'], $_POST['pin3'], $_POST['pin4'], $_POST['pw'])');
09/15/2011 11:09 Jopsi332#10
nein dann geht der script nicht mehr
die "
die du zu ' geändert hast brauhe ich da der anfangs " bei mssql_query("USE [Donate_DBF] ist

e:
ihc kann nicht mal das so setzen $user = $_POST['account']
selbst dabei sagt er mir nen error o.o

edit 2 :
habs jetz so hinbekommen :
PHP Code:
<?php
$server 
"VPS158195\SQLEXPRESS";
$user "";
$pass"";
$username $_POST['account'];
$password $_POST['pw'];
$pin1 $_POST['pin1'];
$pin2 $_POST['pin2'];
$pin3 $_POST['pin3'];
$pin4 $_POST['pin4'];
$email $_POST['email'];


        if(isset(
$_POST['psc_sbm']))
        {
        if (
preg_match('/[^a-zA-Z0-9]/',$_POST['account']))
    {
    die (
' <font color="red">Dein Benutzername enthält unerlaubte Zeichen</font> ');
    }
    else if (empty(
$_POST['account']))
    {    
    die (
' <font color="red">Bitte gebe einen Benutzer namen ein</font> ');
    }
         else if (
preg_match('/[^a-zA-Z0-9]/',$_POST['pin1']))
    {
    die (
' <font color="red">Dein Pin enthält unerlaubte Zeichen</font> ');
    }
    else if (
preg_match('/[^a-zA-Z0-9]/',$_POST['pin2']))
    {
    die (
' <font color="red">Dein Pin enthält unerlaubte Zeichen</font> ');
    }
        else if (
preg_match('/[^a-zA-Z0-9]/',$_POST['pin3']))
    {
    die (
' <font color="red">Dein Pin enthält unerlaubte Zeichen</font> ');
    }
        else if (
preg_match('/[^a-zA-Z0-9]/',$_POST['pin4']))
    {
    die (
' <font color="red">Dein Pin enthält unerlaubte Zeichen</font> ');
    }
    else if (empty(
$_POST['pin1']))
    {
    die (
' <font color="red">Bitte gebe eine Pin ein</font> ');
    }
    else if (empty(
$_POST['pin2']))
    {
    die (
' <font color="red">Bitte gebe eine Pin ein</font> ');
    }
    else if (empty(
$_POST['pin3']))
    {
    die (
' <font color="red">Bitte gebe eine Pin ein</font> ');
    }
    else if (empty(
$_POST['pin4']))
    {
    die (
' <font color="red">Bitte gebe eine Pin ein</font> ');
    }
    else if (empty(
$_POST['email']))
    {
    die (
' <font color="red">Bitte gebe eine E-Mail adresse ein</font> ');
    }
    else if(
strlen($_POST['pin1']) < 4)
    {
    die (
' <font color="red">Bitte gebe eine richtige Pin ein</font> ');
    }
    else if(
strlen($_POST['pin2']) < 4)
    {
    die (
' <font color="red">Bitte gebe eine richtige Pin ein</font> ');
    }
    else if(
strlen($_POST['pin3']) < 4)
    {
     die (
' <font color="red">Bitte gebe eine richtige Pin ein</font> ');
    }
    else if(
strlen($_POST['pin4']) < 4)
    {
    die (
' <font color="red">Bitte gebe eine richtige Pin ein</font> ');
    }
        
$conn mssql_connect($server,$user,$pass);

    if(!
$conn)
    {
    die(
"Connection failed!<br>");
    }
        
$select mssql_select_db("ACCOUNT_DBF",$conn);

        if(!
$select)
        {
        die(
"Can't select Database!<br>");
        }
        
mssql_query("USE [Donate_DBF]
SET NOCOUNT ON
INSERT INTO Donate (Account, Email, Pin1, Pin2, Pin3, Pin4, Password)
VALUES ('
$username', '$email', '$pin1', '$pin2', '$pin3', '$pin4', '$_password')");
        

    
    echo 
'  <font color="green">Deine PaysafeCard wird ueberprueft und du erhaeltst innerhalb der naechsten 24H deine dPoints und eine bestaetigungs E-Mail.</font>  ';
    } 
        

    
?>

    <div style="text-align: center;">
                <img src="img/psc.png" style="margin-top: 5px; margin-bottom: 8px;" />
        <form action="" method="post">
    

            <br>Lightning Points<br/>
            <select name="worth" style="background: url('img/input_txtmid.png'); width: 170px; height: 22px;">
                <option value="10,00">1000 dPoints E10,00</option>
                <option value="25,00">2500 dPoints E25,00</option>
                <option value="50,00">5250 dPoints E50,00</option>
                <option value="100,00">11000 dPoints E100,00</option>
            </select><br/><br/>
            
            
            
<b> <?php echo 'Account Name' ?>:</b> 
            <input type="text" maxlength="30" name="account" style="background: url('img/input_txtmid.png'); width: 120px;" />
            <br/><br/>
             <?php echo 'E-Mail Adresse'?> :</b> 
            <input type="text" maxlength="45" name="email" style="background: url('img/input_txtmid.png'); width: 120px;" />
            <br/><br/>
            <b><?php echo 'PaysafeCard PIN' ?>:</b> 
            <input type="text" maxlength="4" name="pin1" style="background: url('img/input_txtsmall.png'); width: 28px;" />
            <input type="text" maxlength="4" name="pin2" style="background: url('img/input_txtsmall.png'); width: 28px;" />
            <input type="text" maxlength="4" name="pin3" style="background: url('img/input_txtsmall.png'); width: 28px;" />
            <input type="text" maxlength="4" name="pin4" style="background: url('img/input_txtsmall.png'); width: 28px;" />
            <br/><br/>
            <b>*<?php  echo 'Paysafecard Password'?> :</b>
            <input type="text" name="pw" />
            <br/><br/>

            <input type="submit" name="psc_sbm" value="<?php echo 'Donate' ?>" />
        </form>
        <br/>
        <span  id="small">* <?php echo 'PaysafeCard Password, Falls keines auf der Paysafe Card ist, frei lassen.'?> </span> 
    </div>
    <br style="clear: both;" />