PDA

View Full Version : Help with Membership website



kirklogan
10 Aug 2010, 10:32 PM
Hey guys ive been working on making a membership website for a day or two now, and have been having some trouble with my code, i dont claim to be an expert in PHP or SQL but i can generally get the job done, ill post my code below, and any help would be greatly appreciated.

I have a MySQL server set up to handle the input and i am testing this with a login i manually added to the database.

after i input the login and password i get sent to the log.php page (PHP processing page) and there is nothing there whatsoever and it does not redirect me to my success page.

Code for login form:


<div id="mainContent">
<?php
session_name("MyLogin");
session_start();
session_destroy();

if($_GET['login'] == "failed") {
print $_GET['cause'];
}
?>
<form name="login_form" method="post" action="log.php?action=login">
Login: <input type="text" name="user"><BR>
Password: <input type="password" name="pwd"><BR>
<input type="submit">
</form>
</div>



Code for PHP processing page:


<?php
session_name("MyLogin");

if($_GET['action'] == "login") {
$conn = mysql_connect("localhost","thelead2","6WG2NMB(");
$db = mysql_select_db("thelead2_member");
$name = $_POST['user'];
$q_user = mysql_query("SELECT * FROM USERS WHERE login='$name'");

if($_POST['pwd'] == $data['password']) {
session_register("name");
header("Location: success.php");
exit;

} else {
header("Location: login.php?login=failed&cause=".urlencode('Wrong Password'));
exit;
}

} else {
header("Location: login.php?login=failed&cause=".urlencode('Invalid User'));
exit;
}


// if the session is not registered
if(session_is_registered("name") == false) {
header("Location: login.php");
}
?>