Thursday, June 16, 2011

entevava.com: Use database to store user name and password

entevava.com
June 16, 2011 4:46 pm
You have subscribed to these e-mail notices about new posts to the blog.
If you want to change your settings or unsubscribe please visit:
http://entevava.com/post_notification_header/?code=a0ca4a4bc67e212306efaac6b1e301f1&addr=rajileshp.mobile%40blogger.com&

Use database to store user name and password

 //login.html     
Username:

Password:

//index.php < ?php session_start(); if (! isset($_SESSION['name'])) { if (isset($_POST['username'])){ $username = $_POST['username']; $pswd = $_POST['pswd']; $conn=pg_connect("host=localhost dbname=corporate user=root password=") or die(pg_last_error($conn)); $query = "SELECT name FROM users WHERE username='$username' AND pswd='$pswd'"; $result = pg_query($conn, $query); if (pg_num_rows($result) == 1){ $_SESSION['name'] = pg_fetch_result($result,0,'name'); $_SESSION['username'] = pg_fetch_result($result,0,'username'); echo "You're logged in. Feel free to return at a later time."; } } else { include "login.html"; } } else { $name = $_SESSION['name']; echo "Welcome back, $name!"; } ?>

read more...

No comments:

Post a Comment