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

Recommended Answers

All 14 Replies

on your login form what you have set for ACTION ?

<form action=???>

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);
}
}

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.

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");
?>

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"

<?php

error_reporting(0);

?>

is the solution

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.

<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.

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">

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

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

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.

commented: PLease start your own thread and post your code -3

i am having this same issue what should i do? PLEASE HELP

<?php include ('partials/menu.php'); ?>
<div class="main-content">
    <div class="wrapper">
<h1 style="color:#2a9d8f">Add Food!</h1>
<br><br>

<?php

if(isset($_SESSION['upload']))
{
    echo $_SESSION['upload'];
    unset ($_SESSION['upload']);
}


?>

<?php

error_reporting(0);

?>
<form action="" method="POST" enctype="multipart/form-data">
    <table class="tbl-30">
<tr>
    <td>Title:</td>
    <td><input type="text" name="title" placeholder="Enter Title..." /></td>
</tr>
<tr>
    <td>Description:</td>
    <td><textarea name="description" placeholder="Description here please.!" cols="35" rows="6"></textarea></td>
</tr>
<tr>
    <td>Price:</td>
    <td><input type="number" name="price" placeholder="Put Price! in Rs/-" /></td>
</tr>
<tr>
<td>Choose Image:</td>
<td>
<input type="file" name="image"/>
</td>
</tr>
<tr>
    <td>category:</td>
    <td><select type="dropdown" name="category" >
    <option value="1" >Veg</option>
    <option value="2" >Non-Veg</option>

    </select></td>
</tr>
<tr>
    <td>Featured:</td>
    <td><input type="radio" name="featured" value="YES" />YES
  <input type="radio" name="featured" value="NO" />NO</td>

</tr>

<tr>
    <td>Active:</td>
    <td><input type="radio" name="active" value="YES" />YES
    <input type="radio" name="active" value="NO" />NO</td>
</tr>
<tr>
    <td colspan="2">
        <input class="btn-secondary" type="submit" name="submit" Value="Add Food" />
    </td>
</tr>
    </table>

</form>




</div>
</div>


<?php include('partials/footer.php'); ?>


<?php

if(isset($_POST['submit']))
{
    $title = $_POST['title'];
    $description = $_POST['description'];
    $price = $_POST['price'];
    $category = $_POST['category'];

     if(isset($_POST['featured']))
     {
         $featured = $_POST['featured'];
     }
     else{
         $featured="NO";
     }
      if(isset($_POST['active']))
      {
          $active = $_POST['active'];
      }
      else{
          $active = "NO";
      }


if(isset($_FILES['image']['name']))
{
$image_name = $_FILES['image']['name'];
if($image_name!= "")
{
$ext = end(explode('.',$image_name));
$image_name = "Food-Name-".rand(0000.9999).".".$ext;

$src = $_FILES['image']['tmp_name'];

$dst = "../images/food/".$image_name;

$upload = move_uploaded_file($src,$dst);

if($upload==false)
{
    $_SESSION['upload'] = "<div class='error'>Failed to upload Image :( </div>";
    header('location:'.SITEURL.'admin/add-food-php');
    die();
}

}

}
else
{
    $image_name = "";
}

$sql2 = "INSERT INTO tbl_food SET
title='$title',
description='$description',
price=$price,
image_name='$image_name',
category_id=$category,
featured='$featured',
active='$active'

";

$res2 = mysqli_query($conn, $sql2) or die(mysqli_error());

if($res2 == true)
{
$_SESSION['add'] = "<div class='success'>Food Added Successfully.</div>";
header('location:'.SITEURL.'admin/manage-food.php');
}
else
{
    $_SESSION['add'] = "<div class='error'>Failed to add food :(.</div>";
    header('location:'.SITEURL.'admin/add-food.php');
}



}


?>

The error the original poster in this thread had was they had a form that pointed to a page that doesn't exist. If you're getting the same error message as them, you most likely have the same problem.

On line 23 of the code you provided, you have:

<form action="" method="POST" enctype="multipart/form-data">

Please specify an action as the URL to the php page that processes the form.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.