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
https://forums.phpfreaks.com/topic/239886-looking-for-review-of-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.