Pages: 12Next
Current Page: 1 of 2
403 Forbidden - You don't have permission to access / on this server.
Posted by: georgebaker (---.cpe.ge-0-2-0-1101.hknqu1.customer.tele.dk)
Date: June 17, 2009 10:58PM

When i am trying to run my login script i get username and password fields and when i have typed that in and click on "login" i get this error.

My MySQL DB is login6, i have tried a lot of login system as you can see :-)

"You don't have permission to access /login6/< on this server 403 forbidden"

What is wrong ?

Here is the code for the index.php file just in case:
<?
// Use session variable on this page. This function must put on the top of page.
session_start();

////// Logout Section. Delete all session variable.
session_destroy();

$message="";

////// Login Section.
$Login=$_POST['Login'];
if($Login){ // If clicked on Login button.
$username=$_POST['username'];
$md5_password=md5($_POST['password']); // Encrypt password with md5() function.

// Connect database.
$host="localhost"; // Host name.
$db_user="admin"; // MySQL username.
$db_password="1234"; // MySQL password.
$database="login6"; // Database name.
mysql_connect($host,$db_user,$db_password);
mysql_select_db($database);

// Check matching of username and password.
$result=mysql_query("select * from admin where username='$username' and password='$md5_password'"winking smiley;
if(mysql_num_rows($result)!='0'){ // If match.
session_register("username"winking smiley; // Craete session username.
header("location:main.php"winking smiley; // Re-direct to main.php
exit;
}else{ // If not match.
$message="--- Incorrect Username or Password ---";
}

} // End Login authorize check.
?>

<html xmlns="[www.w3.org];
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<? echo $message; ?>
<form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>">
<table>
<tr>
<td>User : </td>
<td><input name="username" type="text" id="username" /></td>
</tr>
<tr>
<td>Password : </td>
<td><input name="password" type="password" id="password" /></td>
</tr>
</table>
<input name="Login" type="submit" id="Login" value="Login" />
</form>
</body>
</html>

And main.php:
<?
// You may copy this PHP section to the top of file which needs to access after login.
session_start(); // Use session variable on this page. This function must put on the top of page.
if(!session_is_registered("username"winking smiley){ // if session variable "username" does not exist.
header("location:index.php"winking smiley; // Re-direct to index.php
}
?>

<html xmlns="[www.w3.org];
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<p>Hello <? echo $_SESSION['username']; ?>! You are now Logged in.</p>
<p><a href="index.php">Logout</a></p>
</body>
</html>

Hope you have some ideas what is wrong.

Thank you in advance for your suggestions

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: yfastud (Moderator)
Date: June 17, 2009 11:04PM

use full tag <?php if short_open_tag is not enable in php.ini through wamp tray icon

to setup db, follow this
[blog.jlbn.net]

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides



Edited 1 time(s). Last edit at 06/17/2009 11:04PM by yfastud.

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: credecop (---.dsl.bell.ca)
Date: June 17, 2009 11:33PM

check this thread for one way to fix the 403 error: [forum.wampserver.com]

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: georgebaker (---.cpe.ge-0-2-0-1101.hknqu1.customer.tele.dk)
Date: June 18, 2009 10:02AM

yfastup

When i change the start of each file to <?php i get this error:

Notice: Undefined index: Login in C:\wamp\www\login6\index.php on line 11

line 11:$Login=$_POST['Login'];

short_open_tag = Off

This error comes when i try to run index.php and not after i have typed username and password and clicked on "login"

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: yfastud (Moderator)
Date: June 18, 2009 02:09PM

Open php.ini through wamp tray icon

Find

error_reporting = E_ALL

Replace w/

error_reporting = E_ALL & ~E_NOTICE

Then save file and restart wamp.

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: georgebaker (---.cpe.ge-0-2-0-1101.hknqu1.customer.tele.dk)
Date: June 18, 2009 06:25PM

Yes! Now the error "Notice: Undefined index: Login in C:\wamp\www\login6\index.php on line 11" is gone and i can type my username and password, but when i click on "login" a new error occour.

Browser shows the folloing error : The website declined to show this website.

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: yfastud (Moderator)
Date: June 18, 2009 09:43PM

$md5_password=md5($_POST['password']); // Encrypt password with md5() function.
not quite sure, but change this line as below and try again
$password=$_POST['password']; // test password w/o md5() function.

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: georgebaker (---.cpe.ge-0-2-0-1101.hknqu1.customer.tele.dk)
Date: June 18, 2009 10:05PM

Sorry the same error message "The website declined to show this website"

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: yfastud (Moderator)
Date: June 18, 2009 10:40PM

through wamp tray icon, enable mod-rewrite and curl then try again

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: georgebaker (---.cpe.ge-0-2-0-1101.hknqu1.customer.tele.dk)
Date: June 18, 2009 10:52PM

Enable mod-rewrite - Where? wamp tray => Apache ?

curl = ?

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: toumimi (---.100.116-78.rev.gaoland.net)
Date: June 18, 2009 11:15PM

What is the url of the bugging page ?
Can you try with Firefox and IE ?

Florian

WampServer Patch (Screenshots)
Topic EN : www.wampserver.com
Topic FR : www.wampserver.com

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: georgebaker (---.cpe.ge-0-2-0-1101.hknqu1.customer.tele.dk)
Date: June 19, 2009 01:29AM

In FireFox vers. 3.0.11- The url is [localhost];? echo $PHP_SELF; ?> - Message: You don't have permission to access /login6/< on this server.

In IE7 - The url is [localhost]; - The website declined to show this website

In Google Chrome vers. 2.0.172.31 - The url is [localhost]; - Message: You don't have permission to access /login6/< on this server.

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: toumimi (---.100.116-78.rev.gaoland.net)
Date: June 19, 2009 01:33AM

Okay I understand..

In your code, you didn't change all php tags...
Please modify
<? echo $PHP_SELF; ?>
by
<?php echo $PHP_SELF; ?>
in your form action param...

And, you should also use $_SERVER['PHP_SELF'] instead of $PHP_SELF...

Florian

WampServer Patch (Screenshots)
Topic EN : www.wampserver.com
Topic FR : www.wampserver.com



Edited 2 time(s). Last edit at 06/19/2009 01:56AM by toumimi.

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: yfastud (Moderator)
Date: June 19, 2009 02:37AM

$PHP_SELF is deprecated; thus, you have error, so you should use $_SERVER['PHP_SELF'] as toumimi recommended winking smiley

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: georgebaker (---.cpe.ge-0-2-0-1101.hknqu1.customer.tele.dk)
Date: June 19, 2009 10:10AM

I have changed all "<?" to "<?php" and changed "$PHP_SELF" to "$_SERVER['PHP_SELF']"

"$password=$_POST['password']; // test password w/o md5() function" is changed back to
"$md5_password=md5($_POST['password']); // Encrypt password with md5() function."

Username and password is "admin" and "1234"
"$db_password="1234"; // MySQL password" is set to "81dc9bdb52d04dc20036dbd8313ed055" instead of "1234" don't know if that is right to do.
The code looks like this now : "$db_password="81dc9bdb52d04dc20036dbd8313ed055"; // MySQL password."

Here is what i get of errors in IE7:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'admin'@'localhost' (using password: YES) in C:\wamp\www\login6\index.php on line 22

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\login6\index.php on line 23

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in C:\wamp\www\login6\index.php on line 23

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\login6\index.php on line 26

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\login6\index.php on line 26

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\login6\index.php on line 27
--- Incorrect Username or Password ---

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: toumimi (---.100.116-78.rev.gaoland.net)
Date: June 19, 2009 11:56AM

Hi,

I prefer those kind of errors winking smiley

mysql_connect() can't establish a connection => Wrong username/password
All other errors are from this first error.
No connection => No database => No query => No mysql_num_row !

Please check your login/pass and you will be right winking smiley

Florian

WampServer Patch (Screenshots)
Topic EN : www.wampserver.com
Topic FR : www.wampserver.com

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: georgebaker (---.cpe.ge-0-2-0-1101.hknqu1.customer.tele.dk)
Date: June 19, 2009 12:05PM

I'm using "admin" and "1234" and i have done that from the beginning. Tried agian of course same result.

How should this line look like ?

$db_password="1234"; // MySQL password or

$db_password="81dc9bdb52d04dc20036dbd8313ed055"

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: georgebaker (---.cpe.ge-0-2-0-1101.hknqu1.customer.tele.dk)
Date: June 19, 2009 12:13PM

There is something else wrong.

Just created another user "bob" "1234" in the database and changed the code to :

$db_user="bob"; // MySQL username.
$db_password="1234"; // MySQL password

Same error.

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: georgebaker (---.cpe.ge-0-2-0-1101.hknqu1.customer.tele.dk)
Date: June 19, 2009 12:17PM

Here is the upated code again.
<?php
// Use session variable on this page. This function must put on the top of page.
session_start();

////// Logout Section. Delete all session variable.
session_destroy();

$message="";

////// Login Section.
$Login=$_POST['Login'];
if($Login){ // If clicked on Login button.
$username=$_POST['username'];
$md5_password=md5($_POST['password']); // Encrypt password with md5() function.
//$password=$_POST['password']; // Encrypt password with md5() function.

// Connect database.
$host="localhost"; // Host name.
$db_user="bob"; // MySQL username.
//$db_password="81dc9bdb52d04dc20036dbd8313ed055"; // MySQL password.
$db_password="1234"; // MySQL password.
$database="login6"; // Database name.
mysql_connect($host,$db_user,$db_password);
mysql_select_db($database);

// Check matching of username and password.
$result=mysql_query("select * from admin where username='$username' and password='$md5_password'"winking smiley;
if(mysql_num_rows($result)!='0'){ // If match.
session_register("username"winking smiley; // Craete session username.
header("location:main.php"winking smiley; // Re-direct to main.php
exit;
}else{ // If not match.
$message="--- Incorrect Username or Password ---";
}

} // End Login authorize check.
?>

<html xmlns="[www.w3.org];
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php echo $message; ?>
<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table>
<tr>
<td>User : </td>
<td><input name="username" type="text" id="username" /></td>
</tr>
<tr>
<td>Password : </td>
<td><input name="password" type="password" id="password" /></td>
</tr>
</table>
<input name="Login" type="submit" id="Login" value="Login" />
</form>
</body>
</html>

Options: ReplyQuote
Re: 403 Forbidden - You don't have permission to access / on this server.
Posted by: toumimi (---.100.116-78.rev.gaoland.net)
Date: June 19, 2009 12:22PM

User must have access right on the database and for this host...
PhpMyAdmin -> Tab Privileges -> Add a new user

User name : Bob
Host : localhost
Password : 1234
Re-type : 1234

Click on Go

Section Database-specific privileges
First dropdown -> login6
Then choose his rights.

If only user, tick Data section rights
If admin of this database, click on Check all link...

Click on Go

After that, retry to load your page...

Florian

WampServer Patch (Screenshots)
Topic EN : www.wampserver.com
Topic FR : www.wampserver.com

Options: ReplyQuote
Pages: 12Next
Current Page: 1 of 2


Sorry, only registered users may post in this forum.