Jump to content

Looking for review of script


HDFilmMaker2112

Recommended Posts

I'm looking to know I could reduce this a bit? I'm thinking that counting the number of rows returned and comparing the password and username typed in matches the one selected from the database is useless, as the select query itself should give me that info. If it returns a row then clearly it's the correct information.

 

So should I remove this?:

$row=mysql_fetch_row($result);
$usernamec=$row[0];
$passwordc=$row[4];

// Register $myusername, $mypassword and redirect to file
if($myusername==$usernamec && $mypassword==$passwordc){

 

<?php
// username and password sent from form 
$myusername=sanitize($_POST['username']); 
$mypassword=kam3(sanitize($_POST['password'])); 

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' AND password='$mypassword'";
$result=mysql_query($sql);


// Mysql_num_row is counting table row
$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
$row=mysql_fetch_row($result);
$usernamec=$row[0];
$passwordc=$row[4];

// Register $myusername, $mypassword and redirect to file
if($myusername==$usernamec && $mypassword==$passwordc){
session_start();
$_SESSION['myusername2']=$myusername;
$_SESSION['mypassword2']=$mypassword;
header("location:index.php?usercp");
}
}

else{ 
if($usernamec!=$myusername || !isset($myusername) || $passwordc!=$mypassword){  
$u2="0";  
} 
header('Location:./index.php?u2='.$u2.''); 
} 
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.