Friday, April 10, 2009

Class 7 Homework (Assign 6?) IMAGE UPLOAD SITE

Well, I hate to say it but once again, this was a very difficult assignment for me. I thought I understood it -- particularly how to 'marry' the registration page with the process_register page and marry the login page with the process_login page -- however, I can't seem to get any information written to the users.txt files. I've tried looking through all my notes, through Amos' examples, through the book "PHP Visual Quickstart Guide" and watching the KillerPHP.com videos. My code seems logical, and it seems to align with everything I've read -- but I'm obviously missing 'something' (I just don't know what it is). Also, I can't seem to get the 'error' messages to appear/pop-up (i.e. Login Failed) on the page. I had to 'cheat' and recreate pages called register_fail.php and login_fail.php (which were replicas of their original pages, with an error message added). Since I can't get anything to write onto the users.txt page, I'm stuck with what to do with the login page (looping through passwords). I've been going round in circles since Sunday night, so I'm just about to give up. I'll try tonight to at least tackle the file upload page, but in the meantime, here are links to my register and login pages:

Register Page
Login Page
Register Fail Page (can't get to write to users.txt file)
Login Fail Page
Index Page (not functional yet)
Image Upload Page

Here's a sample of my code -- again not sure what I'm doing wrong:

PROCESS REGISTRATION PAGE:

/*
$username = trim ($_REQUEST['username']);
$password = trim ($_REQUEST['password']);

$handle = fopen ("users.txt", "a");

$register_info = "Username is {$username}, Password is {password} /n";

if ($handle) {
if ((!empty ($username)) && (!empty ($password))) {
fwrite($handle, $register_info);
header ("Location: login.php");
}

else {
echo "Please enter username and password.";
header ("Location: register_fail.php"); //re-direct to re-register page
}

}

fclose($handle); //close the file

*/

No comments:

Post a Comment