Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
help with string comparing.
Old 08-14-2009, 04:48 PM help with string comparing.
Junior Talker

Posts: 3
Trades: 0
in my admin.php

<?php

if (($_POST["userid"] == "") || ($_POST["password"] == ""))
{
echo "admin is called.";
admin();
}
elseif ($_POST["edit"] == true || (accept($_POST["userid"], $_POST["password"])))
{

echo "update is called.";
if ($_POST["update"] == "true")
{ update($_POST); }
edit( $_POST);
}

else
{
echo $_POST["userid"];
echo '$_POST["userid"]'.'haha';
userIDPasswordAdmin($_POST["userid"], $_POST["password"]);
}


?>

the following is the function.

function accept($userid, $password)
{

echo $userid ." accept function " . $password;
//open file
$f_handel = fopen("Utility/Documents/Admin.txt", "rb") or die ("Can not open the admin file.");
while (!feof($f_handel))
{

$UserID = str_replace("\n", '',(fgets($f_handel, 16)));
$PassWord = str_replace("\n", '',(fgets($f_handel, 16)));


echo $UserID ." read file data " . $PassWord;
if ($UserID == $userid && $PassWord == $password)
{
fclose($f_handel);
echo "<br>return true";
return true;
}

}
fclose($f_handel);

echo "<br>return false";
return false;

}

shiqiangchen.com/Mobile/admin.php
this is the page I get confuse.
The string is the same. Why it return false?
iPhone_Chen is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-14-2009, 04:52 PM Re: help with string comparing.
Junior Talker

Posts: 3
Trades: 0
// use when the password and userid is not correct.
function userIDPasswordAdmin($userid, $password)
{

echo 'Your UserID "' . $userid .'" or Password: "'.$password.'"is not correct. Please try again.';
admin();
}

// print the admin form .
function admin()
{
echo '<form action="admin.php" method="post">

UserID:<input type = "text" name = "userid"/> <br/>
Password:<input type = "password" name = "password" /><br/>
<input type = "submit" />
</form>';


}

userid :JohnChen
password: JohnChen

Last edited by iPhone_Chen; 08-14-2009 at 05:05 PM..
iPhone_Chen is offline
Reply With Quote
View Public Profile
 
Old 08-14-2009, 05:16 PM Re: help with string comparing.
Junior Talker

Posts: 3
Trades: 0
I get it works.
user trim function for all the strings.
iPhone_Chen is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to help with string comparing.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.89549 seconds with 12 queries