bfadler Posted March 7, 2008 Share Posted March 7, 2008 I want to link the user name in the log file to an image that will show on the site. I'm not quite sure where to start, or what I need. This is login page code $filename = "user.log"; $log = fopen($filename, "r"); $contents = file_get_contents($filename); fclose($log); if ($contents == "user1") { $filename = "user.log"; $log = fopen($filename, "r"); fputs($log,""); fclose($log); Here is the code for processing the user name and password, I left out the error function in the center <?php $namePassCombos = array ( "user1" => "user1", ); $loginName = $_POST['loginName']; $passWord = $_POST['passWord']; $passWord = preg_replace ("/</","[",$passWord); $loginName = preg_replace ("/>/","]",$loginName); $loginName = str_replace(".."," ",$loginName); $passWord = str_replace(".."," ",$passWord); $loginName=trim($loginName); $passWord=trim($passWord); function success($loginName) { $filename = "user.log"; $log=fopen($filename, "w+"); fputs($log, $loginName); fclose($log); Header("Location: secure.php"); } --Error function goes here-- if (($loginName == "") || ($passWord == "")) { $notice=0; error($notice); } else if (strcmp($namePassCombos[$loginName],$passWord) != 0) { $notice=1; error($notice); } else if (strcmp($namePassCombos[$loginName],$passWord) == 0) { success($loginName); } ?> Quote Link to comment Share on other sites More sharing options...
frijole Posted March 7, 2008 Share Posted March 7, 2008 I added PHP tags to this first block assuming you just left them out. <?php $filename = "user.log"; $log = fopen($filename, "r"); $contents = file_get_contents($filename); fclose($log); if ($contents == "user1") { $filename = "user.log"; $log = fopen($filename, "r"); fputs($log,""); fclose($log); ?> Here is the code for processing the user name and password, I left out the error function in the center <?php $namePassCombos = array ( "user1" => "user1", ); $loginName = $_POST['loginName']; $passWord = $_POST['passWord']; $passWord = preg_replace ("/</","[",$passWord); $loginName = preg_replace ("/>/","]",$loginName); $loginName = str_replace(".."," ",$loginName); $passWord = str_replace(".."," ",$passWord); $loginName=trim($loginName); $passWord=trim($passWord); function success($loginName) { $filename = "user.log"; $log=fopen($filename, "w+"); fputs($log, $loginName); fclose($log); Header("Location: secure.php"); } --Error function goes here-- if (($loginName == "") || ($passWord == "")) { $notice=0; error($notice); } else if (strcmp($namePassCombos[$loginName],$passWord) != 0) { $notice=1; error($notice); } else if (strcmp($namePassCombos[$loginName],$passWord) == 0) { success($loginName); } ?> Quote Link to comment Share on other sites More sharing options...
bfadler Posted March 7, 2008 Author Share Posted March 7, 2008 Thank you I didn't realize I did that. Quote Link to comment Share on other sites More sharing options...
frijole Posted March 7, 2008 Share Posted March 7, 2008 no problem, as far as your question though. I am not equipped to answer it. Quote Link to comment Share on other sites More sharing options...
soycharliente Posted March 7, 2008 Share Posted March 7, 2008 So you are storing the usernames in a file on the server? Where are the images being stored? And when you say link the username to an image, do you mean? <a href="img/some_image.jpg"><?php echo $username; ?></a> Quote Link to comment Share on other sites More sharing options...
bfadler Posted March 8, 2008 Author Share Posted March 8, 2008 I haven't had a chance to look but a friend helped me out on my coding. He rewrote the code and it said its more secure and less complicated, as well as helped me out on the image coding. So now this thread is useless, sorry for this, but thanks for helping me. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.