Jump to content

show user image upon login


bfadler

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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