Jump to content

Stumped, Login.php not found, etc.


Lucuis

Recommended Posts

Hi everyone, i came across this forum in a desperate search for help. 

 

I've been building a LAMP webserver, to host an e-commerce website for a business.  And so far i've been able to muddle through any issues i had with coding, etc.  But this new problem has me royally stumped. 

 

I've been following a tutorial, http://www.devshed.com/c/a/PHP/Building-an-ECommerce-Site-Part-2-Managing-Users-with-Sessions/5/ , and until now it's been good.  This is part two of three.  Part one worked great, i already have the maintenance screens working.  In part two i was to setup session management and login stuff.  The tutorial provides the bulk of the code, and i only had to change a few things to get it to work.  I then got the additional code for part two, downloaded and placed into the appropriate directories.  I changed the same settings in the application.php file that i did before, but i have a "Not Found" error when i click on the login/sign up buttons on the webpage.  I have scoured the code, and i am at a loss, to why.

 

Anyone interested in helping me concur this code can dl the code from part 2 of the tutorial.  I think it's a problem with the original author's code.  The only things i changed was in the application.php file and i changed the exact same things to the exact same things both times.  It worked originally, but not after i added the part two script to it.  Basically it was a copy paste job. 

 

OR i could email someone my files, so they could see what's wrong.

 

The exact error is;

 

Not Found

 

The requested URL /var/www/html/login.php was not found on this server.

------------------------------------------------------------------------------------------------

Apache/2.2.9 (Fedora) Server at localhost Port 80

 

It's the same for home, and signup buttons.

Link to comment
Share on other sites

$CFG->wwwroot is the path where the script is at relative to the document (domain) root. This is used to form URLs. You have this set to a file system path instead.

 

Based on what you have for $CFG->dirroot, I would guess $CFG->wwwroot should be -

$CFG->wwwroot     = "/FatalIndustries";

 

Link to comment
Share on other sites

Your my hero!

 

I can now access the Login screen, and Signup screen.  However i can't actually login as my admin account.  Not sure why.  I'm going to try a "muddle" through this one, but any insight is welcome:)

 

Thanks again.

 

EDIT: I just tried to create an account using the signup screen.  I get an Alert!  "The URL is not valid and cannot be loaded."

Link to comment
Share on other sites

That code is very old and uses depreciated features that are turned off in current php versions and are eliminated completely in upcoming php6.

 

Turning on full php error reporting would help point out things that are not working because they are dependent on something that is turned off in php. You should also be learning php, developing php code, or debugging php code on a system where full php error reporting is turned on to get php to help you. Are you doing this on a system where error_reporting is set to E_ALL and display_errors is set to ON?

Link to comment
Share on other sites

EDIT: I just tried to create an account using the signup screen.  I get an Alert!  "The URL is not valid and cannot be loaded."

 

Here is how troubleshooting programming works -

 

Look at that output that has something wrong with it.

 

Find the php code that is responsible for generating that wrong output. Read the php code to determine what about it is causing that wrong output. Backtrack through the code and data until you find the source of the problem.

 

In your case, what is wrong with the URL? Is the file name wrong? Is the path part of the URL wrong?

 

In the php code that is outputting that URL, what variable or other value is responsible for whatever is wrong in the resulting URL? Backtrack through the code to find where that variable or value is being set and make it the correct value.

Link to comment
Share on other sites

That code is very old and uses depreciated features that are turned off in current php versions and are eliminated completely in upcoming php6.

 

Turning on full php error reporting would help point out things that are not working because they are dependent on something that is turned off in php. You should also be learning php, developing php code, or debugging php code on a system where full php error reporting is turned on to get php to help you. Are you doing this on a system where error_reporting is set to E_ALL and display_errors is set to ON?

 

I'm not sure if error_reporting is set to E_ALL, or if display errors is set to ON.  If it isn't, how would i go about enabling it?  I'm on a Linux based system, Fedora Core 9 to be specific, if that matters.  I think i'm using php5, whatever Fedora comes with.

 

When i was setting up the maintenance screens, when something was wrong it displayed an error, quite specific, in the browser which helped me resolve it.  Would this be the type of error reporting you're talking about?

 

Time for bed though, i'll be looking at it fresh tomorrow.

 

Thanks again.

 

 

Link to comment
Share on other sites

Well i turned on error_reporting(E_ALL); by putting that into the application.php file...i think.  I put it before any of the other commands except the obvious <? that has to go first.  I'm not sure how it's supposed to work but i'm not getting any error reporting. 

 

When i go to log in using my admin account it just refreshes the page without logging me in.  No errors, nothing.

 

I tried typing in incorrect info, because it's supposed to give me an error "incorrect login", but it just refreshes the page again.  I tried to backtrack through the code, looking in the files that relate to the pages i'm having issues with to no avail.  Everything looks normal in my eyes.

 

My level of understanding just isn't quite there.  I mostly know html from building a couple websites a few years back.  And i know that one character out of place messes stuff up.  And it seems the same with php.  So what i know of php is the stuff i have learned lately, and the similarities it has with html.

 

You mentioned some code is old, old enough to not work right.  That could be part of the reason i'm having troubles finding out whats wrong.  Because 8 years ago it's right, lol.  Since i used an old tutorial i can't tell the difference.

 

In short, my "muddling" didn't work and, i need help.

Link to comment
Share on other sites

Weird, won't let me edit my posts atm.

 

Anywas, i went in search of ways to update the old, or less proper code.  I came across one post which stated to change all the <? to <?php and to change all the <?= to <?php echo.  So i went thorugh every single line of code and updated it.  I think i fixed a few things that would have messed up down the road.  But alas i'm still stumped on the login screen.

 

As stated before, when i attempt to login, all it does is refresh the screen.  Whether i input the correct admin login or just a bunch of numbers.

Link to comment
Share on other sites

OK, i finally figured out how to get the errors displayed.

 

First error with logging in;

Notice: A session had already been started - ignoring session_start() in /var/www/html/FatalIndustries/login.php on line 23

 

Second error on the signup page;

Fatal error: Call to undefined function phpperr() in /var/www/html/FatalIndustries/users/templates/signup_form.php on line 10

 

I'll post the code if you need it.

Link to comment
Share on other sites

I managed to fix the second error.  However when i click on the signup button, an Alert pops up reading "The URL is not valid and cannot be loaded."  Would that be considered a logical error?  One of those really tough ones to find?

Link to comment
Share on other sites

Weird, when i went to check if anyone had responded to my last posts, i found that my topic was tagged as "Solved."  The original issues was resolved, but it uncovered more, therefore the topic is not finished.

 

Anyways, i have this error;

Notice: A session had already been started - ignoring session_start() in /var/www/html/FatalIndustries/login.php on line 23

 

Do i not need *session_start()*  ?

 

I tried removing it, and the Notice disappears, but don't i need a start session command, for logins etc?

Link to comment
Share on other sites

TY, redarrow.  Not 100% sure if it worked, but the "notice" is gone.  I read through the link you gave.  And i think i sort of understand it, but i'm not sure where to start.

 

Like i stated earlier i'm getting that alert reading "The URL is not valid and cannot be loaded."  My guess is that it's something wrong in three pages of my code.  the Login.php, login_form.php, and perhaps application.php.  I'm pretty much a complete noob at this, so maybe you can spot something i can't.

 

Application.php

<?php session_start();
/* application.php (c) 2000 Ying Zhang (ying@zippydesign.com)
*
* TERMS OF USAGE:
* This file was written and developed by Ying Zhang (ying@zippydesign.com)
* for educational and demonstration purposes only.  You are hereby granted the
* rights to use, modify, and redistribute this file as you like.  The only
* requirement is that you must retain this notice, without modifications, at
* the top of your source code.  No warranties or guarantees are expressed or
* implied. DO NOT use this code in a production environment without
* understanding the limitations and weaknesses pretaining to or caused by the
* use of these scripts, directly or indirectly. USE AT YOUR OWN RISK!
*/

/* turn on verbose error reporting (15) to see all warnings and errors */
ini_set('display_errors','On');
error_reporting(E_ALL);

/* define a generic object */
class object {};

/* setup the configuration object */
$CFG = new object;

$CFG->dbhost = "localhost";
$CFG->dbname = "FatalIndustries";
$CFG->dbuser = "FatalIndustries";
$CFG->dbpass = "*******";   *changed for obvious reasons*

$CFG->wwwroot     = "/FatalIndustries";
$CFG->dirroot     = "/var/www/html/FatalIndustries";
$CFG->templatedir = "$CFG->dirroot/templates";
$CFG->libdir      = "$CFG->dirroot/lib";
$CFG->imagedir    = "$CFG->wwwroot/images";

$CFG->wordlist    = "$CFG->libdir/wordlist.txt";
$CFG->support     = "support@mymarket.com";

/* define database error handling behavior, since we are in development stages
* we will turn on all the debugging messages to help us troubleshoot */
$DB_DEBUG = true;
$DB_DIE_ON_FAIL = true;

/* load up standard libraries */
require("$CFG->libdir/stdlib.php");
require("$CFG->libdir/dblib.php");
require("$CFG->libdir/mymarket.php");

/* setup some global variables */
$ME = qualified_me();

/* start up the sessions, to keep things clean and manageable we will just
* use one array called SESSION to store our persistent variables */

session_register("SESSION");

/* connect to the database */
db_connect($CFG->dbhost, $CFG->dbname, $CFG->dbuser, $CFG->dbpass);
?>

 

Login.php

<?php session_start();
/* login.php (c) 2000 Ying Zhang (ying@zippydesign.com)
*
* TERMS OF USAGE:
* This file was written and developed by Ying Zhang (ying@zippydesign.com)
* for educational and demonstration purposes only.  You are hereby granted the 
* rights to use, modify, and redistribute this file as you like.  The only
* requirement is that you must retain this notice, without modifications, at
* the top of your source code.  No warranties or guarantees are expressed or
* implied. DO NOT use this code in a production environment without
* understanding the limitations and weaknesses pretaining to or caused by the
* use of these scripts, directly or indirectly. USE AT YOUR OWN RISK!
*/

/******************************************************************************
* MAIN
*****************************************************************************/

include("application.php");

/* start up the sessions, to keep things clean and manageable we will just
* use one array called SESSION to store our persistent variables */
session_register("SESSION");

/* form has been submitted, check if it the user login information is correct */
if (match_referer() && isset($HTTP_POST_VARS)) {
$user = verify_login($HTTP_POST_VARS["username"], $HTTP_POST_VARS["password"]);

if ($user) {
	$SESSION["user"] = $user;
	$SESSION["ip"] = $REMOTE_ADDR;		

	/* if wantsurl is set, that means we came from a page that required
	 * log in, so let's go back there.  otherwise go back to the main page */
	$goto = empty($SESSION["wantsurl"]) ? $CFG->wwwroot : $SESSION["wantsurl"];
	header("Location: $goto");
	die;

} else {
	$errormsg = "Invalid login, please try again";
	$frm["username"] = $HTTP_POST_VARS["username"];
}
}

include("$CFG->templatedir/login_form.php");

/******************************************************************************
* FUNCTIONS
*****************************************************************************/

function verify_login($username, $password) {
/* verify the username and password.  if it is a valid login, return an array
* with the username, firstname, lastname, and email address of the user */

$qid = db_query("
SELECT username, firstname, lastname, email, priv
FROM users
WHERE username = '$username' AND password = '" . md5($password) . "'
");

return db_fetch_array($qid);
}

?>

 

and login_form.php

<html>
<head>
<title>MyMarket Login</title>
</head>
<?php ?>
<style>
.h1      { font-family: Arial, sans-serif; font-size: 14pt; font-weight: bold; }
.label   { font-family: Arial, sans-serif; font-size: 10pt; font-weight: bold; }
.normal  { font-family: Arial, sans-serif; font-size: 10pt; }
.warning { font-family: Arial, sans-serif; font-size: 12pt; font-weight: bold; color: #ff0000; }
</style>

<body bgcolor=#ffffff link=#0000ff vlink=#000099 alink=#ff0000>
<div class=h1>MyMarket Login Screen<hr size=1></div>

<p>
<table cellpadding=20>
<tr valign=top>
<td width=300 class=normal>
<p>If you do not already have an account, please
<a href="<?php echo $CFG->wwwroot?>/users/signup.php">sign up for an account</a> now.

<p>If you have an account but have forgotten your password,
<a href="<?php echo $CFG->wwwroot?>/users/forgot_password.php">click here</a> to recover
your password.

<p>If you have do not wish to login yet,
<a href="<?php echo $CFG->wwwroot?>">click here</a> to return to the home page.
</td>

<td bgcolor=#f0f0f0>
<?php if (! empty($errormsg)) { ?>
	<div class=warning align=center><?php pv($errormsg) ?></div>
<?php } ?>

<form name="entryform" method="post" action="<?php echo $CFG->wwwroot?>/login.php">
<table>
<tr>
	<td class=label>Username:</td>
	<td><input type="text" name="username" size=20 value="<?php pv($frm["username"]) ?>"></td>
</tr>
<tr>
	<td class=label>Password:</td>
	<td><input type="password" name="password" size=20></td>
</tr>
<tr>
	<td></td>
	<td><input type="submit" value="Login">
		<input type="button" value="Cancel" onClick="javascript: history.go(-1)">
		<p class=normal>
		  <a href="<?php echo $CFG->wwwroot?>/users/signup.php">Sign up for an account</a>
		| <a href="<?php echo $CFG->wwwroot?>/users/forgot_password.php">Forgot my password</a>
	</td>
</table>
</form>
</td>
</tr>
</table>

</body>
</html>

 

I also can't login.  I have even tried to input incorrect info to see if the "incorrect info" error comes up, but nothing.  Like i said a few posts back, when i try to login it pretty much just refreshes the page.

 

Last time i follow a dated tutorial, lol.

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.