Jump to content

Recommended Posts

I am creating a simple login system....each member has a folder and in the folder is a password file (password.php), which will contain something like this:

 

<?php $pass = "password"; ?>

 

and When you log in, this is the code that checks to see if the input password is the same as the one in the file...the problem is, when I include that file, it wont read it, help?

 

<?php

include("up.php");
$iuser = $_POST['user'];
$ipass = $_POST['pass'];
$pull = $iuser . "/info/password.php";
include("$pull");

if($ipass == $pass) {
    setcookie("UserName", $user, time()+3600, "/", false);
    setcookie("Password", $pass, time()+3600, "/", false);

echo "<META HTTP-EQUIV='Refresh'
      CONTENT='3; URL=http://12.27.247.70:8000/New/" . $user . "'>Logged In.<br><br><a href='http://12.27.247.70:8000/New/" . $iuser . "'>Home</a>";

  } else {

echo "<META HTTP-EQUIV='Refresh'
      CONTENT='3; URL=http://12.27.247.70:8000/New'>Invalid username or password.<br><br><a href='http://12.27.247.70:8000/New'>Home</a>";

  }
?>

Link to comment
https://forums.phpfreaks.com/topic/36604-include-function-help/
Share on other sites

This is something that really should be in a database. :/

 

What happens when you print $pull? Is the value what you expect?

Are all these user folders in the same directory as this file? You may need to adjust the path.

 

So right after you include it, if you print $pass, it is empty?

Link to comment
https://forums.phpfreaks.com/topic/36604-include-function-help/#findComment-174370
Share on other sites

Here's some a test for some possible errors.

<?
$inc = $iuser . "/info/password.php";

if (file_exists($inc))
{
if ( (fileperms($inc) & 4) == 4)
	include($inc);
else
	echo "dood, you don't have read permission for this file. (User: Other)";
}
else
echo "dood, check this path. IS it right? ->".$inc;
?>

Link to comment
https://forums.phpfreaks.com/topic/36604-include-function-help/#findComment-174408
Share on other sites

your problem seems to be your choice of variable names.

 

You have set the $_POST data ($_POST['user'] and $_POST['pass']) names to the same variables you are pulling your password from.

 

What I mean is, $user and $pass are the exact same as $_POST['user'] and $_POST['pass']

 

try changing your variable names (i.e. $p = 'PASSWORD') and see if that works better.

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/36604-include-function-help/#findComment-174412
Share on other sites

your problem seems to be your choice of variable names.

 

You have set the $_POST data ($_POST['user'] and $_POST['pass']) names to the same variables you are pulling your password from.

 

What I mean is, $user and $pass are the exact same as $_POST['user'] and $_POST['pass']

 

try changing your variable names (i.e. $p = 'PASSWORD') and see if that works better.

 

$user and $pass are not the same as $_POST['user'] and $_POST['pass'], unless you have your register_globals set to ON, which you shouldn't.

Link to comment
https://forums.phpfreaks.com/topic/36604-include-function-help/#findComment-174613
Share on other sites

<?php
if(isset($_POST['submit'])){//do you have this already? because it is essential to pass data from form to php...
include("up.php");
$iuser = $_POST['user'];
echo $iuser;//double check if the string is expected
$ipass = $_POST['pass'];
echo $ipass;//double check if the string is expected
include("$iuser/info/password.php");//I dont think pausing the echo is necassary
continued...//below stays the same
}//dont forget to close the isset...
?>

If the echoes dont come out right, then there is no point continuing further, so get your POST successfully sorted out first.

Ted

Link to comment
https://forums.phpfreaks.com/topic/36604-include-function-help/#findComment-174626
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.