Résolu Corriger mon script PHP login

Statut
N'est pas ouverte pour d'autres réponses.

ShA.Dev

Membre premium
Premium
Inscription
4 Mai 2013
Messages
910
Réactions
236
Points
11 931
RGCoins
25
Bonsoir , j'ai un petit soucis avec mon petit login.

Enfaite j'aimerais que quand dans ma DB que si la dans la colonne banned il y'a "YES" alors il va mettre une message box .

Mais que si il y'a rien ou NO , alors il continue son chemin , voici mon code PHP et voici mon code C#

Code:
   private void secondOriginButton1_Click(object sender, EventArgs e)
        {
            try
            {



                using (WebClient wc = new WebClient())
                {
                    wc.Credentials = new NetworkCredential("XXXXXXXX", "XXXXXXX"); // We give the HTaccess logins
                    string rLogin = wc.DownloadString("https://asinith.us/Login/login.php?username=" + textBox1.Text + "&password=" + textBox2.Text + "&hwid=" + Value()) + "&banned="; // Check in DB if username & password & hwid & banned matches

                    if (rLogin == "0")
                    {
                        MessageBox.Show("Your login information might be invalid :/.", "Invalid user.", MessageBoxButtons.OK, MessageBoxIcon.Error); // If login is wrong then display that.
                    }
                    else if (rLogin == "1")
                    {
                        MessageBox.Show("Hi " + textBox1.Text + " you're connected ! ", "Connected", MessageBoxButtons.OK, MessageBoxIcon.Information); // If login is good then display that + Open new form and close old one.
                        this.Hide();
                        Form2 F2 = new Form2();
                        F2.Show();

                    }
                    else if (rLogin == "2") // Banned = Yes in DB then toggle banned message.
                    {
                        MessageBox.Show("You have been permanently banned from FrenchCore.CC", "Banned.", MessageBoxButtons.OK, MessageBoxIcon.Error); // If user is banned then display that.
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Sorry! There is a problem with our server please check it out at https://status.frenchcore.cc/", "Server error.", MessageBoxButtons.OK, MessageBoxIcon.Error); // If there is an exception display that message

            }


        }

Et voici le PHP je me suis trompé c'est sur x)

PHP:
<?php

// 0 = Erreur de connexion
// 1 = Connexion réussite
// 2 = BANNIS

include("config.php");


$username = $_GET['username'];
$pass = $_GET['password'];
$hwid = $_GET['hwid'];
$banned = $_GET['banned'];

$private_key = 'XXXXXXX';


function f_crypt($private_key, $str_to_crypt) {
    $private_key = md5($private_key);
    $letter = -1;
    $new_str = '';
    $strlen = strlen($str_to_crypt);

    for ($i = 0; $i < $strlen; $i++) {
        $letter++;
        if ($letter > 31) {
            $letter = 0;
        }
        $neword = ord($str_to_crypt{$i}) + ord($private_key{$letter});
        if ($neword > 255) {
            $neword -= 256;
        }
        $new_str .= chr($neword);
    }
    return base64_encode($new_str);
}



$password = f_crypt($private_key, $pass);

$req = $bdd->prepare('SELECT id FROM users WHERE username = :username AND password = :password AND hwid = :hwid AND banned = :banned');
$req->execute(array(
    'username' => $username,
    'hwid' => $hwid,
    'password' => $password,
    'banned' => $banned));

$resultat = $req->fetch();

if (!$resultat)
{
    echo '0';
  
}
else
{
    echo '1';
}
else
    if ($banned == 'YES')
{
    echo '2';
}

?>

Merci à vous !​
 
Au niveau des conditions dans ton code PHP ça ne va pas, enchaîne tes conditions comme ceci :

if{}
elseif{}
elseif{}

Sinon ça m'a l'air correct :mmh:
Merci , mais j'avais pensé à
Code:
if(!$resultat)
{
echo '0';
}
else if ($banned == "YES")
{
echo "2";
}
else
{
echo "1";
}

Ca m'a l'air incorrect mon tool ne fait rien quand je clique sur login je suis sur que je loupe une étape dans le PHP le C# est sur a 100% de mon point de vue
 
Merci , mais j'avais pensé à
Code:
if(!$resultat)
{
echo '0';
}
else if ($banned == "YES")
{
echo "2";
}
else
{
echo "1";
}

Ca m'a l'air incorrect mon tool ne fait rien quand je clique sur login je suis sur que je loupe une étape dans le PHP le C# est sur a 100% de mon point de vue
Mais déjà en utilisant ton navigateur tu peux voir si ton code fonctionne en simulant les variables via l'URL, essaye déjà par là tu trouveras facilement ta réponse ;)
 
Mais déjà en utilisant ton navigateur tu peux voir si ton code fonctionne en simulant les variables via l'URL, essaye déjà par là tu trouveras facilement ta réponse ;)
Des que je rajoute un else ou else if ça me met une erreur HTTP ERROR 500
 
Tu as changé ton code php depuis ?
Code:
$password = f_crypt($private_key, $pass);

$req = $bdd->prepare('SELECT id FROM users WHERE username = :username AND password = :password AND hwid = :hwid AND banned = :banned');
$req->execute(array(
    'username' => $username,
    'hwid' => $hwid,
    'password' => $password,
    'banned' => $banned));

$resultat = $req->fetch();

if(!$resultat)
    
{
echo "0";
}
else
{
echo "1";
}
else if

{
    ($banned == "YES")
echo "2";
}

?>
 
Salut,@Āsā.
Ta demande est-elle résolue ?

Si oui, je t'invite à cliquer sur Cette réponse a répondu à ma question sur le message qui t'a aidé pour rajouter le préfixe résolu à la discussion. :)

Bonne soirée,
FlamHackPS3
 
Statut
N'est pas ouverte pour d'autres réponses.
Retour
Haut