Reply
PHP Remote (somewhat) Array
Old 03-17-2006, 04:01 PM PHP Remote (somewhat) Array
Average Talker

Posts: 27
login.php
PHP Code:
<?php
$passwords 
file('password.php');
echo 
"$passwords";
$passwords_array = array($passwords);

if((
array_key_exists($_POST['user'], $passwords_array))
        and
    (
$passwords_array[$_POST['user']] == $_POST['pass'])){ 
?>
<?php $user 
=  $_POST['user']; ?>
<form method="post" action="upload.php" enctype="multipart/form-data">
Select a file to upload<br>
<input type="hidden" value="<?php echo "$user"?>" name="user" />
<input type="file" name="userfile"/><br>
<input type="submit" value="Upload">
</form>
<?php
}
else{
?>
<center>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<table width="313" border="0">
    <tr>
      <td width="75"><p align="right">Username:</p>
        <p align="right">Password:</p></td>
      <td width="228"><p>
        <input type="text" name="user" />
      </p>
        <p>
          <input type="password" name="pass" />    
            </p></td>
    </tr>
  </table>
<input type="submit" value="Login" />
</form>
<P>
Uploads files to your folder. Files examined daily.
</center>
<?php

}

?>
password.php
PHP Code:
'abc' => '123'
,'def' => '456'
,'ghi' => '789' 
I can't for the life of me figure out what's wrong.
enerbrat is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 03-17-2006, 05:24 PM Re: PHP Remote (somewhat) Array
Christopher's Avatar
Iced Cap

Latest Blog Post:
PHP and Unicode with UTF-8
Posts: 3,108
Location: Toronto, Ontario
You can't just pass a string to array() and have it eval'ed as PHP. Either eval it as PHP like so (not desired):
PHP Code:
eval('$passwords_array = array(' $passwords ');'); 
Or make password.php an actual array and simply include it:
login.php
PHP Code:
include('password.php'); // now $passwords_array exists
// .. the rest 
passwords.php:
PHP Code:
<?php

$passwords_array
('abc' => '123',
'def' => '456',
'ghi' => '789');

?>
Christopher is offline
Reply With Quote
View Public Profile Visit Christopher's homepage!
 
Old 03-17-2006, 06:15 PM Re: PHP Remote (somewhat) Array
Super Talker

Posts: 144
it would also help to know the format of the file. perhaps you could use fgetcsv to put the contents of the file into an array for you.
__________________
create.vibe
web development portfolio
createvibe.com is offline
Reply With Quote
View Public Profile Visit createvibe.com's homepage!
 
Old 03-18-2006, 05:39 PM Re: PHP Remote (somewhat) Array
Average Talker

Posts: 27
Well, I tried your first suggestion and got

"
Parse error: syntax error, unexpected T_DOUBLE_ARROW in c:\wamp\www\test\password.php on line 2
"
enerbrat is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP Remote (somewhat) Array
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB 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.12525 seconds with 13 queries