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); } ?> Link to comment https://forums.phpfreaks.com/topic/94958-show-user-image-upon-login/ 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); } ?> Link to comment https://forums.phpfreaks.com/topic/94958-show-user-image-upon-login/#findComment-486462 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. Link to comment https://forums.phpfreaks.com/topic/94958-show-user-image-upon-login/#findComment-486471 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. Link to comment https://forums.phpfreaks.com/topic/94958-show-user-image-upon-login/#findComment-486491 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> Link to comment https://forums.phpfreaks.com/topic/94958-show-user-image-upon-login/#findComment-486503 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. Link to comment https://forums.phpfreaks.com/topic/94958-show-user-image-upon-login/#findComment-486600 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.