0

Hi all

I have uncountered a problem which has me totally confused. The problem is I have created a website with a login form. Everything so far has been working fine. but then when I try to login all of a sudden I’m hit with a

"Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
29/08/2011 15:05:42
Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1
."

coming from my localhost. I don't think it has anything to do with the actual login script itself but more to do with the Apache config files/modules. Any suggestions would be much appreciated as this problem has me stumped

Thanks

Edited by codeblock: n/a

5
Contributors
12
Replies
22
Views
6 Years
Discussion Span
Last Post by vinsanity2109
0

on your login form what you have set for ACTION ?

<form action=???>

Hi sv3tli0,

<form action="<?php echo [B]pf_script_with_get($SCRIPT_NAME)[/B]; ?>" method="post">

if(!function_exists('[B]pf_script_with_get[/B]')){	

function pf_script_with_get($script) {
	$page = $script;
	$page = $page . "?";

	foreach($_GET as $key => $val) {
		$page = $page . $key . "=" . $val . "&";
	}
  
	return substr($page, 0, strlen($page)-1);
}
}
0

I think you have some big errors at your code.
First I don't understand how you use $_GET at your function.. ?

one normal login form should be as

<form action="login.php" method="post">
<input type="text" name="username">
<input type="password" name="password">
<input type="submit" value="Login"></form>

At this case after submit you will POST this data in php format:
$_POST["username"]="THE_NAME_YOU_ENTER";
$_POST["password"]="THE_PASSWORD_YOU_ENTER";

You cant use login.php?username=XXX&password=XXX for ACTION.

0

I think you have some big errors at your code.
First I don't understand how you use $_GET at your function.. ?

one normal login form should be as

<form action="login.php" method="post">
<input type="text" name="username">
<input type="password" name="password">
<input type="submit" value="Login"></form>

At this case after submit you will POST this data in php format:
$_POST["username"]="THE_NAME_YOU_ENTER";
$_POST["password"]="THE_PASSWORD_YOU_ENTER";

You cant use login.php?username=XXX&password=XXX for ACTION.

This is the login page which should explain the whole process

<?php  
require("sessions.php");
require("config.php");
require("functions.php");

if(isset($_SESSION['USERNAME']) == TRUE){
	header("Location: " . $config_basedir . "userhome.php");
}

if(isset($_POST['submit'])) {

	$sql = "SELECT * FROM users,register WHERE users.id = register.user_id AND register.username = '" . $_POST['username'] . "' AND register.password = '" . $passwordcrypted . "';";
	
	$result = mysql_query($sql);
	$numrows = mysql_num_rows($result);
	
	session_register("USERNAME");
	session_register("USERID");
	
	if(isset($numrows) == 1) {	
		$row = mysql_fetch_assoc($result);
		
		if($row['active'] == 1) {
				
		$_SESSION['USERNAME'] = $row['username'];
		$_SESSION['USERID'] = $row['id'];	

        if(isset($_GET['ref'])){
          $ref = $_GET['ref'];
			switch($_GET['ref']) {

				case "newitem":
					header("Location: " . $config_basedir . "/newitem.php");
				break;
				           			
				case "viewregister":
					header("Location: " . $config_basedir . "/viewregister.php?id=" . $_GET['id']);
				break;
				
				case "userhome":
					header("Location: " . $config_basedir . "/userhome.php");
				break;
               				
				default:
					header("Location: " . $config_basedir);   
				break;
			}  
          }			
		}  
		else {
			require("header.php");
			echo "This account is not verified yet. You were emailed a link to verify the account. Please click on the link in the email to continue.";
		}			
	}
	else {
		header("Location: " . $config_basedir . "/login.php?error=1");
	}
}
else {

	require("header.php");

	echo "<hr><h1><label class='titleBlue'>Account Login</label></h1></hr>";
	echo "<hr></hr>";
    if(isset($_GET['error'])){
       $error = $_GET['error'];
		switch($_GET['error']){			
		 case "username":
		 echo "<strong><h4>Incorrect login, please enter correct username!</h4>";
		break; 
		 case "password1":
		 echo "<strong><h4>Incorrect login, please enter correct password!</h4></strong>";
		break; 
	  default:
		echo "<strong><h4>Incorrect username or password, please try again!</h4>";
		break;

	}
}	
	
?> 
<form action="<?php echo pf_script_with_get($SCRIPT_NAME); ?>" method="post">

<table>
<tr><td colspan="2" bgcolor="#0000CD"> <label class="texts"><strong>Use a valid username and password to gain access to your userspace.</strong></label></td>
</tr>
<tr>
	<td>Username</td>
	<td><input type="text" STYLE="foreground:#ffffff; color:#eaeaea; id="username"name="username" value="bob" onfocus="clearMe(this)"/></td>
</tr>
<tr>
	<td>Password</td>
	<td><input type="password" id="password1"name="password1" value="passwordy"></td>
</tr>
<tr>
	<td></td>
	<td align = right><input type="submit" name="submit" value="Login!"></td>
</tr>
</table>



</form>

<?php
}

require("footer.php");
?>
0

This is the login page which should explain the whole process

<?php  
require("sessions.php");
require("config.php");
require("functions.php");

if(isset($_SESSION['USERNAME']) == TRUE){
	header("Location: " . $config_basedir . "userhome.php");
}

if(isset($_POST['submit'])) {

	$sql = "SELECT * FROM users,register WHERE users.id = register.user_id AND register.username = '" . $_POST['username'] . "' AND register.password = '" . $passwordcrypted . "';";
	
	$result = mysql_query($sql);
	$numrows = mysql_num_rows($result);
	
	session_register("USERNAME");
	session_register("USERID");
	
	if(isset($numrows) == 1) {	
		$row = mysql_fetch_assoc($result);
		
		if($row['active'] == 1) {
				
		$_SESSION['USERNAME'] = $row['username'];
		$_SESSION['USERID'] = $row['id'];	

        if(isset($_GET['ref'])){
          $ref = $_GET['ref'];
			switch($_GET['ref']) {

				case "newitem":
					header("Location: " . $config_basedir . "/newitem.php");
				break;
				           			
				case "viewregister":
					header("Location: " . $config_basedir . "/viewregister.php?id=" . $_GET['id']);
				break;
				
				case "userhome":
					header("Location: " . $config_basedir . "/userhome.php");
				break;
               				
				default:
					header("Location: " . $config_basedir);   
				break;
			}  
          }			
		}  
		else {
			require("header.php");
			echo "This account is not verified yet. You were emailed a link to verify the account. Please click on the link in the email to continue.";
		}			
	}
	else {
		header("Location: " . $config_basedir . "/login.php?error=1");
	}
}
else {

	require("header.php");

	echo "<hr><h1><label class='titleBlue'>Account Login</label></h1></hr>";
	echo "<hr></hr>";
    if(isset($_GET['error'])){
       $error = $_GET['error'];
		switch($_GET['error']){			
		 case "username":
		 echo "<strong><h4>Incorrect login, please enter correct username!</h4>";
		break; 
		 case "password1":
		 echo "<strong><h4>Incorrect login, please enter correct password!</h4></strong>";
		break; 
	  default:
		echo "<strong><h4>Incorrect username or password, please try again!</h4>";
		break;

	}
}	
	
?> 
<form action="<?php echo pf_script_with_get($SCRIPT_NAME); ?>" method="post">

<table>
<tr><td colspan="2" bgcolor="#0000CD"> <label class="texts"><strong>Use a valid username and password to gain access to your userspace.</strong></label></td>
</tr>
<tr>
	<td>Username</td>
	<td><input type="text" STYLE="foreground:#ffffff; color:#eaeaea; id="username"name="username" value="bob" onfocus="clearMe(this)"/></td>
</tr>
<tr>
	<td>Password</td>
	<td><input type="password" id="password1"name="password1" value="passwordy"></td>
</tr>
<tr>
	<td></td>
	<td align = right><input type="submit" name="submit" value="Login!"></td>
</tr>
</table>



</form>

<?php
}

require("footer.php");
?>

Taking a second look, i think it has more to do with my sessions. if i type the whole url i'll get the error message

"Notice: Undefined index: USERNAME in C:\xampp\htdocs\site\auction\userhome.php on line 14"

0

I think that you have not just one problem .

<td><input type="text" STYLE="foreground:#ffffff; color:#eaeaea;" id="username"name="username" value="bob" onfocus="clearMe(this)"/></td>

First correct this line because you haven't close the style tag


Can you open your page in browser, click your right button of mouse open source code and check <FORM ACTION=to what>
Your problem is there because when you submit FORM your browser redirect you to the page written in the ACTION and there is your problem.

0
<form action="<?php echo pf_script_with_get([B]$SCRIPT_NAME[/B]); ?>" method="post">

The bold text should be $_SERVER.

What is the purpose that the function pf_script_with_get doing ?

If you want the form action to the same page. Use $_SERVER which returns the current url including query string (ie., you can get those with $_GET method ), or use $_SERVER which returns the current url without query string.

0

Try to replace your

<form action="<?php echo pf_script_with_get($SCRIPT_NAME); ?>" method="post">

with

<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
0

Try to replace your

<form action="<?php echo pf_script_with_get($SCRIPT_NAME); ?>" method="post">

with

<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">

Thanks for your help guys but i've found the problem and its solved

0

Thanks for your help guys but i've found the problem and its solved

-1

i need help all of my pages wont appear except my front page. what to do?
it says
Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.

Votes + Comments
PLease start your own thread and post your code
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.