If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Login Coding Doesn't Work.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-05-10, 09:41
don_log don_log is offline
Registered User
 
Join Date: Jun 2008
Location: pakistan
Posts: 109
Login Coding Doesn't Work.

The coding which is i used i get from a website people appriciate this script so i get that one but the login script doesn't work i have a table
called userid,username,password

and the inserted values is userid 1 ,username admin,password waridtel but some thing went wrong the script is here see and tell me
PHP Code:
<?php
include('vars.php');
include(
'connection.php');

//check that the user is calling the page from the login form and not accessing it directly 

//and redirect back to the login form if necessary 

if (!isset($username) || !isset($password)) { 
echo 
"<script type='text/javascript'>";

echo 
"window.location = 'index.php'";
echo 
"</script>"



//check that the form fields are not empty, and redirect back to the login page if they are 


elseif (empty($username) || empty($password)) { 
echo 
"<script type='text/javascript'>";
echo 
"window.location = 'index.php' ";
echo 
"</script>"

else{ 

//convert the field values to simple variables 
//add slashes to the username and md5() the password 


$user addslashes($_POST['username']); 
$pass md5($_POST['password']); 

$result=mysql_query("select * from user where username='$user' AND password='$pass'"); 

//check that at least one row was returned 

//$rowCheck = mysql_num_rows($result); 
//if($rowCheck = 1 ){ 
while($row mysql_fetch_assoc($result)){ 

  
//start the session and register a variable 

  
session_start(); 
  
session_register('username'); 

  
//successful login code will go here... 
  
echo 'Success!'

  
//we will redirect the user to another page where we will make sure they're logged in 
echo "<script type='text/javascript'>";
echo 
"window.location = 'index2.php' ";
echo 
"</script>";

  } 

/*  } 
  else { 

  //if nothing is returned by the query, unsuccessful login code goes here... 

  echo 'Incorrect login name or password. Please try again.'; 
  } */
  


?>
Reply With Quote
  #2 (permalink)  
Old 06-05-10, 09:42
don_log don_log is offline
Registered User
 
Join Date: Jun 2008
Location: pakistan
Posts: 109
if possible then give me the explanation of coding like isset function, || pipesign function and other explanation or provide me another one solid coding another question i will ask later after this solution.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On