| Darkprince97 |
| | Ciao a tutti 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
| | |
| |
|