Transentient
10-16-2011, 01:26 PM
Hi all....again
Thanks for all the help so far....learning alot
Following some help from one very helpfull member i managed to get my very simple php login working.
Essentially a form submits data to the code, code compares against a MySQL database.
I have found a little bug, if i copy and paste the url of the protected page into the browser it bypasses the login and goes staright to it. I'm thinking maybe need to use a session which expires either on logout, or after a time delay, or when the browser is closed? Although i'm not sure, my code so far, thanks to JasonDFR, is
<?php
$username = $_POST["username"];
$password = $_POST["password"];
$Login = $_GET["login"];
if($Login == 'yes') {
$con = mysql_connect("mysql19.streamline.net", "homenetne1", "****");
mysql_select_db("homenetne1");
$get = mysql_query("select count(id) FROM Login WHERE user='$username' and pass='$password'");
$result = mysql_result($get, 0);
if($result != 1) {
echo "Invalid Login";
} else {
header( 'Location: http://www.homenet-nexus.co.uk/secure_page.html' ) ;
}
}
?>
Done a little research on sessions, but not sure how to use, and implement within my current code?
Any help, as always will be gratefully accepted
thanks all
Thanks for all the help so far....learning alot
Following some help from one very helpfull member i managed to get my very simple php login working.
Essentially a form submits data to the code, code compares against a MySQL database.
I have found a little bug, if i copy and paste the url of the protected page into the browser it bypasses the login and goes staright to it. I'm thinking maybe need to use a session which expires either on logout, or after a time delay, or when the browser is closed? Although i'm not sure, my code so far, thanks to JasonDFR, is
<?php
$username = $_POST["username"];
$password = $_POST["password"];
$Login = $_GET["login"];
if($Login == 'yes') {
$con = mysql_connect("mysql19.streamline.net", "homenetne1", "****");
mysql_select_db("homenetne1");
$get = mysql_query("select count(id) FROM Login WHERE user='$username' and pass='$password'");
$result = mysql_result($get, 0);
if($result != 1) {
echo "Invalid Login";
} else {
header( 'Location: http://www.homenet-nexus.co.uk/secure_page.html' ) ;
}
}
?>
Done a little research on sessions, but not sure how to use, and implement within my current code?
Any help, as always will be gratefully accepted
thanks all