Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * SimpleManager
- * for TheSpartan
- *
- * @author Nami <Vendethiel> D0C
- */
- $host = 'localhost';
- $user = 'root';
- $pswd = '';
- $dbname = 'accounts';
- $db_layer = 'mysql';
- $table = 'users';
- $champ1 = 'user'; //à mettre dans ?.. ET le nom de la colonne dans la DB
- $champ2 = 'pass'; //à mettre dans ?.. ET le nom de la colonne dans la DB
- try
- {
- $cnx = new PDO($mysql.':host='.$host.';dbname='.$dbname, $user, $pswd);
- $cnx->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }
- catch (PDOException $e)
- {
- exit('Connexion error: '.$e->getMessage());
- }
- if (!isset($_GET[$champ1]))
- return; //wrong request
- $user = $_GET[$champ1];
- if (isset($_GET[$champ2]))
- { //add an user
- $pass = $_GET[$champ2];
- $cnx->query('INSERT INTO `'.$table.'` (`'.$champ1.'`, `'.$champ2.'`) VALUES ('.$cnx->quote($user).', '.$cnx->quote($pass).')');
- }
- else
- {
- $row = $cnx->query('SELECT `'.$champ2.'` FROM `'.$table.' WHERE `'.$champ1'` = '.$cnx->quote($user).' LIMIT 1');
- echo $row->fetchColumn();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement