Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Make your access codes as constants
- define("DBHOST", "localhost");
- define("DBUSER", "root");
- define("DBPWD", "2468");
- define("DBNAME", "information");
- $myusername = $_POST['username'];
- $mypassword = $_POST['password'];
- $tablename = "members";
- $link = dbconnect();
- $sql = "SELECT * FROM `" . $tablename . "` WHERE `username` = '" . $myusername ."' and `password` = '" . $mypassword . "' ";
- // note the syntax!!!
- function dbconnect()
- {
- $link = mysql_connect(DBHOST, DBUSER, DBPWD) or die (mysql_error("Error "));
- mysql_select_db(DBNAME) or die(mysql_error("Could not select database"));
- return($link);
- }
- $result = mysql_query($sql);
- $row = mysql_fetch_array($result);
- // you dont need to free result or mysql_connect as of the newer version of php these are done automatically
- if ($row['username'] == "")
- {
- header("location:fail.php");
- }
- else{
- header("location:success.php");
- }
- ?>
- <head>
- </head>
- <body>
- <form method="post">
- <input name="password" type="text" />
- <input name="password" type="text" />
- <input type="submit" value="Login" />
- </form>
- </body>
Add Comment
Please, Sign In to add comment