bocochoco
-
Posts
3 -
Joined
-
Last visited
Never
Posts posted by bocochoco
-
-
I have been there before. Typically if you are writing something for them, they will own the copyright for it. If you signed a paper or anything, the fine print would probably have said something about that.
-
Hey all, I'm new. I hope you don't hold that against me. I could really use some help. I have spent the last 3 hours trying to figure out what is wrong with my script. It is a simple login script, data entered by the user is compared with data pulled from a mysql database. It seems to have a problem comparing the password values. I have tried everything that I can think of, yet it has all failed. Any noticable problems?
Login.php, user entered information is posted here.
[code]<?
require("config.php");
require("include.php");
import_request_variables("p", "pv_");
$pv_pwd = md5($pv_pwd);
$con = mysql_connect($mysql_server, $mysql_user, $mysql_pass);
$sdb = mysql_select_db($mysql_db, $con);
$query = "SELECT username, password FROM users WHERE username='" . $pv_uid . "' AND password='" . $pv_pwd . "'";
//echo "<br><br>" . $query;
$qu = mysql_query($query, $con);
$row = mysql_fetch_assoc($qu);
$uid = $row['username'];
$pwd = $row['password'];
if(stringcomp(($uid, $pv_uid, 0) == 1) && (stringcomp($pwd, $pv_pwd, 1) == 1))
echo "Login Success.";
else
{
echo "Login Failed.";
// Next 2 lines for debugging purposes.
echo "<br>$pv_uid == $uid<br>" . stringcomp($uid, $pv_uid) . "<br>";
echo "<br>$pv_pwd == $pwd<br>" . stringcomp($pwd, $pv_pwd) . "<br>";
}
mysql_close($con);
?>[/code]
include.php, where the stringcomp function is located.
[code]<?php
//Returns: 0 if both strings are not identical
// 1 if both strings are identical.
function stringcomp($string1, $string2, $toup)
{
$false = 0;
$ct = 0;
if($toup == 1)
{
$string1 = strtoupper($string1);
$string2 = strtoupper($string2);
}
if(strlen($string1) <> strlen($string2))
return 0;
while($ct < strlen($string1))
{
if(ord(substr($string1, $ct, 1)) !== ord(substr($string2, $ct, 1)))
$false++;
$ct++;
if($false <> 0)
return 0;
else
return 1;
}
}
?>[/code]
Any help would be greatly appreciated. Thanks
string comparison failing
in PHP Coding Help
Posted