08-09-05, 08:05 PM
Wannabe Coder
Join Date: Apr 2005
Location: Knob Noster, Mo
Posts: 228
Thanks: 1
Thanked 0 Times in 0 Posts
Help Please
ok when I do this and try to login I get nothing.
PHP Code:
<?
include_once( '../config.php' );
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
$username = $_POST [ 'username' ];
$password = md5 ( $_POST [ 'password' ]);
$sql = "SELECT * FROM users WHERE username=' $username '" ;
$q = mysql_query ( $sql );
while( $row = mysql_fetch_array ( $q ))
{
if( $row [ 'username' ] == $username && $row [ 'password' ] == $password ){
if( $row [ 'admin' ] == "1" ){
echo '<script>
function put_cookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
document.cookie = curCookie;
}
var now = new Date();
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
put_cookie("VDoD_Mem_Data_admin", "true", now, "/", "div.conshosting.net");
put_cookie("VDoD_Mem_Data_user", "true", now, "/", "div.conshosting.net");
put_cookie("VDoD_Mem_Data_username", "' . $username . '", now, "/", "div.conshosting.net");
window.location="home.php?op=admin";
</script>' ;
}elseif( $row [ 'admin' ] != "1" ){
echo '<script>
function put_cookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
document.cookie = curCookie;
}
var now = new Date();
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
put_cookie("VDoD_Mem_Data_user", "true", now, "/", "dev.conshosting.net");
put_cookie("VDoD_Mem_Data_username", "' . $username . '", now, "/", "dev.conshosting.net");
window.location="home.php?op=user";
</script>' ;
}else{
}
}elseif( $row [ 'username' ] != $username && $row [ 'password' ] != $password ){
echo '<script>
window.location="../index.php";
</script>' ;
}else{
}
}
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
08-09-05, 09:01 PM
Junior Code Guru
Join Date: Sep 2004
Posts: 458
Thanks: 0
Thanked 0 Times in 0 Posts
Your problem is here
It's not doing anything because more than likely it's not matching the password. When it doesn't match the password, you're having it.. do nothing.
The two checks you have are 'both match' or 'none match', but remember you specified the username in the sql query so you don't need to check that at all.
08-09-05, 09:20 PM
Wannabe Coder
Join Date: Apr 2005
Location: Knob Noster, Mo
Posts: 228
Thanks: 1
Thanked 0 Times in 0 Posts
still not working.
PHP Code:
<?
include_once( '../config.php' );
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
$username = $_POST [ 'username' ];
$password = md5 ( $_POST [ 'password' ]);
$sql = "SELECT * FROM users WHERE username=' $username '" ;
$q = mysql_query ( $sql );
while( $row = mysql_fetch_array ( $q ))
{
if( $row [ 'password' ] == $password ){
if( $row [ 'admin' ] == "1" ){
echo '<script>
function put_cookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
document.cookie = curCookie;
}
var now = new Date();
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
put_cookie("VDoD_Mem_Data_admin", "true", now, "/", "div.conshosting.net");
put_cookie("VDoD_Mem_Data_user", "true", now, "/", "div.conshosting.net");
put_cookie("VDoD_Mem_Data_username", "' . $username . '", now, "/", "div.conshosting.net");
window.location="home.php?op=admin";
</script>' ;
}else{
echo '<script>
function put_cookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
document.cookie = curCookie;
}
var now = new Date();
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
put_cookie("VDoD_Mem_Data_user", "true", now, "/", "dev.conshosting.net");
put_cookie("VDoD_Mem_Data_username", "' . $username . '", now, "/", "dev.conshosting.net");
window.location="home.php?op=user";
</script>' ;
}
}else{
echo '<script>
window.location="../index.php";
</script>' ;
}
}
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
?>
08-09-05, 09:41 PM
Junior Code Guru
Join Date: Sep 2004
Posts: 458
Thanks: 0
Thanked 0 Times in 0 Posts
You also haven't got it doing anything if it never found the row with the username in the first place
08-09-05, 10:04 PM
Wannabe Coder
Join Date: Apr 2005
Location: Knob Noster, Mo
Posts: 228
Thanks: 1
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Sabu
You also haven't got it doing anything if it never found the row with the username in the first place
What do you mean?
08-10-05, 03:18 AM
Code Guru
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
firstly whats with the
??
also this might be a better solution:
PHP Code:
<?
include_once( '../config.php' );
$username = $_POST [ 'username' ];
$password = md5 ( $_POST [ 'password' ]);
$sql = "SELECT * FROM users WHERE username=' $username ' AND password=' $password ' AND admin='1'" ;
$q = mysql_query ( $sql );
$check = mysql_num_rows ( $q );
if ( $check == 1 ) {
setcookie ( "VDoD_Mem_Data_admin" , "true" , time ()+ 31536000 , "/" , "div.conshosting.net" );
setcookie ( "VDoD_Mem_Data_user" , "true" , time ()+ 31536000 , "/" , "div.conshosting.net" );
setcookie ( "VDoD_Mem_Data_username" , $username , time ()+ 31536000 , "/" , "div.conshosting.net" );
header ( "Location: home.php?op=admin" );
}
else {
$query = mysql_query ( "SELECT * FROM users WHERE username=' $username ' AND password=' $password '" );
$check = mysql_num_rows ( $query );
if ( $check == 1 ) {
setcookie ( "VDoD_Mem_Data_user" , "true" , time ()+ 31536000 , "/" , "div.conshosting.net" );
setcookie ( "VDoD_Mem_Data_username" , $username , time ()+ 31536000 , "/" , "div.conshosting.net" );
header ( "Location: home.php?op=user" );
}
else {
header ( "Location: ../index.php" );
}
}
?>
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.
codR.us <-- Submit and vote for your favorite code snippets with codR.us.
XEWeb.net <-- The ultimate PHP resource network.
08-10-05, 06:28 AM
Wannabe Coder
Join Date: Apr 2005
Location: Knob Noster, Mo
Posts: 228
Thanks: 1
Thanked 0 Times in 0 Posts
Is there something I am missing on that because It doesn't work eather
08-10-05, 06:57 AM
Code Guru
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
Yes, are you sure the username and password are correct?
What is the error message your getting?
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.
codR.us <-- Submit and vote for your favorite code snippets with codR.us.
XEWeb.net <-- The ultimate PHP resource network.
08-10-05, 07:39 AM
Newbie Coder
Join Date: Mar 2005
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
What's error message you receive.
also worth to check if your host server turn on the global register on htaccess.
Quote:
Originally Posted by connor
ok when I do this and try to login I get nothing.
PHP Code:
<?
include_once( '../config.php' );
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
$username = $_POST [ 'username' ];
$password = md5 ( $_POST [ 'password' ]);
$sql = "SELECT * FROM users WHERE username=' $username '" ;
$q = mysql_query ( $sql );
while( $row = mysql_fetch_array ( $q ))
{
if( $row [ 'username' ] == $username && $row [ 'password' ] == $password ){
if( $row [ 'admin' ] == "1" ){
echo '<script>
function put_cookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
document.cookie = curCookie;
}
var now = new Date();
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
put_cookie("VDoD_Mem_Data_admin", "true", now, "/", "div.conshosting.net");
put_cookie("VDoD_Mem_Data_user", "true", now, "/", "div.conshosting.net");
put_cookie("VDoD_Mem_Data_username", "' . $username . '", now, "/", "div.conshosting.net");
window.location="home.php?op=admin";
</script>' ;
}elseif( $row [ 'admin' ] != "1" ){
echo '<script>
function put_cookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
document.cookie = curCookie;
}
var now = new Date();
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
put_cookie("VDoD_Mem_Data_user", "true", now, "/", "dev.conshosting.net");
put_cookie("VDoD_Mem_Data_username", "' . $username . '", now, "/", "dev.conshosting.net");
window.location="home.php?op=user";
</script>' ;
}else{
}
}elseif( $row [ 'username' ] != $username && $row [ 'password' ] != $password ){
echo '<script>
window.location="../index.php";
</script>' ;
}else{
}
}
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
08-10-05, 04:18 PM
Wannabe Coder
Join Date: Apr 2005
Location: Knob Noster, Mo
Posts: 228
Thanks: 1
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by FiRe
Yes, are you sure the username and password are correct?
What is the error message your getting?
It just redirects me back to the login page.
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off