[Guida]Php & Autoit Login v3.0

« Older   Newer »
  Share  
Darkprince97
CAT_IMG Posted on 18/11/2010, 20:42     +1   -1




Ciao a tutti :D
Allora, ho deciso di sviluppare la v 3.0 del mio login obbligatorio , implementando questa volta un database con cui interagire in php.
Abbiamo bisogno di un db su un sito ( io uso altervista).

Server Part PHP
+Crea_tabella.php
CODICE
<?php
$User     = "***";        // Il Vostro User
  $Pass     = "***";        // La vostra password

$con=mysql_connect("localhost",$user,$pass);
if(!$con)die('Could not connect:'.mysql_error());
mysql_select_db("my_db",$con);//Il nome del vostro DB
$sql="CREATE TABLE accounts(uid int(10) NOT NULL auto_increment,username varchar(15),password varchar(15),PRIMARY KEY(uid))";
$query=mysql_query($sql,$con);
if(!$query)echo("Tabella non creata");
else echo("Tabella creata");
mysql_close($con);
?>

A Cosa ci serve ? Semplice,a creare la tabella nella quale poi metteremo gli accounts
+Login.php
CODICE
<?php
  $dbHost     = "localhost";        
  $User     = "***";    
  $Pass     = "***";    
if ($_GET["action"] == "add") {
$con=mysql_connect("localhost",$user,$pass);
if(!$con)die('Could not connect:'.mysql_error());

mysql_select_db("my_db",$con); //nome del vostro db
$req = mysql_query("INSERT INTO accounts (username ,password) VALUES ('".$_GET["u"]."', '".$_GET["p"]."')", $con);
if($req){
   echo("L'account è stato creato con successo!");
   }else{
   echo("Account non aggiunto!");
   }
   }
if ($_GET["action"] == "login") {
$mysql = mysql_connect("localhost",$user,$pass);
   mysql_select_db("my_proplayers",$mysql);
       $result = mysql_query("SELECT * FROM accounts", $mysql);
       if (!$result) die(mysql_error());
       
       while ($row = mysql_fetch_array($result)) {
           
                       if (isset($_GET["username"]) && isset($_GET["password"]) && $username==$row['username'] && $password==$row['password']) {
                               
echo ("Loggato con successo");
}
}
}        
   ?>

a Cosa ci serve questo ? A far sì che quando visiteremo la pagina e setteremo come action "add" lui adderà l'user
CODICE
http://pincopallino.altervista.org/login.php?action=add&u=Ciao&p=ciao

Questo addera nel Db User: Ciao e Password:Ciao
CODICE
http://pincopallino.altervista.org/login.php?action=login&username=ciao&password=ciao

Questo invece ci loggherà

------------------
+Client Part
------------------
Autoit
CODICE
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <INET.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Accounts", 165, 233, 192, 124)
$Group1 = GUICtrlCreateGroup("Create", 8, 8, 145, 105)
$Input1 = GUICtrlCreateInput("ID", 16, 24, 121, 21)
$Input2 = GUICtrlCreateInput("Password", 16, 48, 121, 21)
$Button1 = GUICtrlCreateButton("Add", 16, 72, 75, 25, $WS_GROUP)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Login", 8, 120, 145, 105)
$Input3 = GUICtrlCreateInput("Id", 16, 136, 121, 21)
$Input4 = GUICtrlCreateInput("Password", 16, 160, 121, 21)
$Button3 = GUICtrlCreateButton("Login", 16, 184, 75, 25, $WS_GROUP)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$WINDOW = ObjCreate("Shell.Explorer.2")
$VISUALWINDOW = GUICtrlCreateObj($WINDOW, 136, 0, 11, 17)

GUICtrlSetState(-1, $GUI_HIDE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
               Case $GUI_EVENT_CLOSE
                       Exit
               case $button1
                       $WINDOW.NAvigate("http://sito.altervista.org/Login.php?action=add&u="&GuiCtrlread($input1)&"&p="&Guictrlread($input2))
               case $button3
               $source = _INetGetSource("http://sito.altervista.org/Login.php?action=login&username="&GuiCtrlread($input3)&"&password="&Guictrlread($input4))
                       if stringinstr($source,"Loggato con successo") Then
                               msgbox(64,"Loggato","Loggato con successo")
                       Else
                               msgbox(16,"Non Loggato","Non loggato")
                       EndIf
                       
                       
       EndSwitch
WEnd

Ecco fatto , usatelo per il bene u.u
Thanks to:
Zyrel
Sky92
 
Top
ACIDBURN16
CAT_IMG Posted on 18/11/2010, 20:44     +1   -1




Buona guida, Bravo ;)
 
Top
Darkprince97
CAT_IMG Posted on 18/11/2010, 20:45     +1   -1




è più Php che autoit,ma può essere sempre utile
 
Top
xMasteRx
CAT_IMG Posted on 18/11/2010, 20:48     +1   -1




Niente male ^^
 
Top
Darkprince97
CAT_IMG Posted on 18/11/2010, 21:04     +1   -1




grazie ^^
 
Top
Gianlu-thebest
CAT_IMG Posted on 19/11/2010, 07:56     +1   -1




Bravo.. ma non è sicuro!
Puoi criptare con l'udf www.lahace.altervista.org/sred.php?name=Crp.au3&mode=script
 
Top
Darkprince97
CAT_IMG Posted on 19/11/2010, 13:48     +1   -1




appena ho tempo ci lavoro :D
 
Top
CAT_IMG Posted on 21/11/2010, 16:59     +1   -1
Avatar

So creare belle gui

Group:
Member
Posts:
374
Reputazione:
0
Location:
C:\Windows\System32 \hacktooth.exe

Status:


una domanda e se le rischieste sono POST ? si puo pure fare un auto login?
 
Top
Darkprince97
CAT_IMG Posted on 22/11/2010, 17:24     +1   -1




Devi fare il form per le richieste in Post e adattare il codice.
Per la seconda non sono sicuro di aver capito.Intendi salvare la sessione ?
 
Top
CAT_IMG Posted on 22/11/2010, 20:56     +1   -1
Avatar

So creare belle gui

Group:
Member
Posts:
374
Reputazione:
0
Location:
C:\Windows\System32 \hacktooth.exe

Status:


CITAZIONE (Darkprince97 @ 22/11/2010, 17:24) 
Devi fare il form per le richieste in Post e adattare il codice.
Per la seconda non sono sicuro di aver capito.Intendi salvare la sessione ?

no per il php no ho problemi ad adattare il codice...ma siccome non hai url in chiaro cosa metti qui?
SPOILER (click to view)
$source = _INetGetSource("http://sito.altervista.org/Login.php?action=login&username="&GuiCtrlread($input3)&"&password="&Guictrlread($input4))

BANANE? xD
 
Top
Darkprince97
CAT_IMG Posted on 23/11/2010, 13:43     +1   -1




Mhhh,devi fare una richiesta tramite IE del tipo:
CODICE
#include <IE.au3>
$Input_User = inputbox("Login","Inserisci il nome utente")
$Input_Pass = inputbox("Login","Inserisci la password")
$oIE=_IECreate("http://www.unfair-gamers.com/login1.php",0,0)
           ProgressSet(20)
           $o_form = _IEFormGetObjByName($oIE,"Login_Form")
           $o_login = _IEFormElementGetObjByName ($o_form, "username")
           $o_password = _IEFormElementGetObjByName ($o_form, "password")
           $o_signin = _IEFormElementGetObjByName ($o_form, "submit")
           _IEFormElementSetValue ($o_login, $Input_User )
           _IEFormElementSetValue ($o_password, $Input_Pass )
           _IEAction ($o_signin, "click")
           Sleep(3000);aspetta 3 secondi (intanto che si carica la pagina)
           if not StringInStr(_IEBodyReadText($oIE),"Hai inserito un nome utente o password non validi.") Then
               ;login effettuato correttamente
;codice
           Else
               MsgBox(46,"Errore","Hai inserito un nome utente o password non validi.")
               ShellExecute("http://www.unfair-gamers.com/")
               _IEQuit($oIE)
               Exit
           EndIf

Vecchio codice di SnFede preso su UG,va adattato
 
Top
xMasteRx
CAT_IMG Posted on 8/12/2010, 14:59     +1   -1




Metto come importante, è sempre molto utile la guida ;)
 
Top
Darkprince97
CAT_IMG Posted on 8/12/2010, 15:32     +1   -1




Grazie Master =)
 
Top
thanzeon
CAT_IMG Posted on 14/12/2011, 17:00     +1   -1




darkprince!!!! ho un piccolo problema diciamo...

CODICE
Could not connect:Access denied for user 'serverbruno'@'localhost' (using password: NO)


ho provato in tutti i modi a cambiare password e utente dai .php ...

non funzionava uguale, allora ho provato anche a cambiare localhost... idem.

help please?
 
Top
CAT_IMG Posted on 14/12/2011, 17:13     +1   -1

So implementare gli object

Group:
Admin
Posts:
1,215
Reputazione:
+150

Status:


CITAZIONE (thanzeon @ 14/12/2011, 17:00) 
darkprince!!!! ho un piccolo problema diciamo...

CODICE
Could not connect:Access denied for user 'serverbruno'@'localhost' (using password: NO)


ho provato in tutti i modi a cambiare password e utente dai .php ...

non funzionava uguale, allora ho provato anche a cambiare localhost... idem.

help please?

Sei arrivato un annetto in ritardo... Comunque il tuo problema riguarda il database, hai i dati per autenticarti? O meglio, hai un database?
 
Top
22 replies since 18/11/2010, 20:42   847 views
  Share