} if (mysql_num_rows($result) > 0) { //log the user in $row = mysql_fetch_assoc($result); loggin($row['user_id'],$row['user_name']); } else { //insert a new record echo $sql = 'INSERT INTO `user` (`user_id`, `user_name`, `user_real_name`, `user_password`, `user_newpassword`, `user_newpass_time`, `user_email`, `user_options`, `user_touched`, `user_token`, `user_email_authenticated`, `user_email_token`, `user_email_token_expires`, `user_registration`, `user_editcount`) VALUES (NULL, \''.ucfirst($userName).'\', \'\', \''.$userPass.'\', \'\', NULL, \'\', \'\', \'\', \'\', NULL, NULL, NULL, NULL, NULL);'; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit(); } loggin(mysql_insert_id(),$userName); } mysql_free_result($result); /* //save data $fp = fopen("data.txt", "a"); fwrite ($fp, $string."\n\n"); fclose ($fp);*/ //return blank image //header("Content-type: image/pjpeg");
<div class="container"> <div class="col-1"> <?php include "./content/side.php"; ?> <div class="big-col"> <div class="banner"> <a href=""><img src="./img/site/banner2.png" alt="MitraCollection.com" title="MitraCollection.com"></a> </div> <div class="produk-title"> <h1>Login::</h1> </div> <?php if (isset($_POST['login'])) { loggin($_POST['email'], $_POST['password']); } ?> <div class="list-p"> <div class="f-master"> <div class="bg-f"> <div class="b-h">FORM LOGIN::</div> <form action="<?php echo htmlspecialchars('index.php?url=login'); ?> " method="post"> <div class="f-name">Email</div><div class="f-in"><input class="in"type="text" name="email"></div> <div class="f-name">Password</div><div class="f-in"><input class="in" type="password" name="password"></div> <div class="f-btn"> <input class="btn-sub" type="submit" value="login" name="login"> </div> </form>
<?php require_once 'include.php'; if (isset($_POST['is_logged'])) { return is_logged(); } if (isset($_POST['loggin'])) { return loggin(); } if (isset($_POST['logout'])) { return loggout(); }
<?php header("Content-type: text/plain"); $realm = 'Private Site'; // sets this realm $nonce = uniqid(); // Create a random unique id $loggin = loggin(); // If there was no loggin, require login if (is_null($loggin)) { requireLogin($realm, $nonce); } $digestParts = parser($loggin); // User and password $user = '******'; $passwd = '1234'; // Based on all the info we gathered we can figure out what the response should be $A1 = md5("{$user}:{$realm}:{$passwd}"); $A2 = md5("{$_SERVER['REQUEST_METHOD']}:{$digestParts['uri']}"); // Make validations $validate = md5("{$A1}:{$digestParts['nonce']}:{$digestParts['nc']}:{$digestParts['cnonce']}:{$digestParts['qop']}:{$A2}"); // If the credential subscribed was not correct requier new login if ($digestParts['response'] != $validate) { requireLogin($realm, $nonce); } else { echo "Welcome {$user}!"; } // function that returns the login function loggin() { $loggin = "";