Jump to content

Recommended Posts

I made a search engine to search my database for specific users ( well I used a tutorial ). I'm not getting any errors atleast when loading the page which is a first for me. However, now I am tackled by something new. When entering the keywords and submitting the search I get:

Access forbidden!

 

You don't have permission to access the requested object. It is either read-protected or not readable by the server.

 

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

Error 403

127.0.0.1

04/30/07 11:09:21

Apache/2.2.16 (Win32) PHP/5.3.3

 

Which is odd for me because I am using the same config.php with connection code to connect to the db which I used with all my other pages. And in those pages I have been able to add/delete/edit and display records from the database tables. Does this have something to do with it being a search engine?

 

Here is my code:


<html>
<head>
</head>
<body>
<h2>Search</h2> 
<form name="search" method="post" action="<?=$PHP_SELF?>">
Seach for: <input type="text" name="find" /> in 
<Select NAME="field">
<Option VALUE="fname">First Name</option>
<Option VALUE="sname">Last Name</option>
<Option VALUE="sno">Profile</option>
</Select>
<input type="hidden" name="searching" value="yes" />
<input type="submit" name="search" value="Search" />
</form>
</body>
</html>

<?php 
//This is only displayed if they have submitted the form 
$searching ='searching';
if ($searching =="yes") 
{ 
echo "<h2>Results</h2><p>"; 

//If they did not enter data then they receive an error
if ($find == "") 
{ 
echo "<p>You forgot to enter a search term"; 
exit; 
} 

// Otherwise connect to database
include 'includes/config.php';
include 'includes/functions.php';

connect(); 

// filtering
$find = strtoupper($find); 
$find = strip_tags($find); 
$find = trim ($find); 

// search for term in specified field
$data = mysql_query("SELECT * FROM student WHERE upper($field) LIKE'%$find%'"); 

// display results
while($result = mysql_fetch_array( $data )) 
{ 
echo $result['fname']; 
echo " "; 
echo $result['sname']; 
echo "<br>"; 
echo $result['sno']; 
echo "<br>"; 
echo "<br>"; 
} 

//Counts number or results and display message if there we're non
$anymatches=mysql_num_rows($data); 
if ($anymatches == 0) 
{ 
echo "Sorry, but we can not find an entry to match your query<br><br>"; 
} 

//And we remind them what they searched for 
echo "<b>Searched For:</b> " .$find; 
} 
?> 

 

Any ideas? Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/235950-error-403-for-search-engine/
Share on other sites

When leaving the action attribute empty the form does nothing when being submitted. Also for what it's worth tried copying the php section and saving it as a different file called search2.php and then using action="search2.php". But still only the form and nothing happens when submitting.

Tried fixing the error 403. Someone had a similar problem and in his php.ini file (im using easyphp) he turned "short_open_tags" on. Fixed his problem. I did the same, however, now I'm stuck with a new error:

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

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.