Jump to content

Archived

This topic is now archived and is closed to further replies.

insrtsnhere13

403 Forbidden Error when attempting to post

Recommended Posts

Hey guys, recently installed WAMP on my laptop and Im having some trouble posting.

i get this error:

Forbidden

You don't have permission to access /< on this server.
Apache/2.0.55 (Win32) PHP/5.1.2 Server at localhost Port 80

using this script:

[code]

<?php
if (!isset($_POST['submit'])) {
?>

<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
Name of page (ex: Home, News):<br>
<input type="text" name="page" size="50"><br><br>
Heading to appear above content ("Business Hours:, Services:,"):<br>
<input type="text" name="title" size="50"><br><br>
Content to be displayed:<br>
<textarea name="content" rows=7 cols=46></textarea><br><br>
<input type="submit" name="submit" value="Submit"></form>

<?php
}
else {
include("connect.php");
    
    $page = $_POST['page'];
    $title = $_POST['title'];
    $content = $_POST['content'];
    
    $sql = "INSERT INTO pages VALUES ('$page', '$title', '$content')";
    $result = mysql_query($sql) or die ("Error in query: $sql. ".mysql_error());
    
    // print message with ID of inserted record
    echo "New record inserted with ID ".mysql_insert_id();
    
    // close connection
    mysql_close($connection);
}
?>[/code]

Share this post


Link to post
Share on other sites
Not sure about the error, but you do have an extra "=" in this line:

[code]<form action="<?=$_SERVER['PHP_SELF']?>"[/code]

Should be:
[code]<form action="<? $_SERVER['PHP_SELF'] ?>"[/code]

Share this post


Link to post
Share on other sites
one thing i found, i think my includes arent working for some reason.. like i said, i just installed WAMP and havent messed with any configurations.. if someone could help me..

What I did was moved all of the actuall code to a file called post.php and left the form and renamed it form.html

when i had an include calling my database info i got a mysql error saying it couldnt connect using OBDC@localhost or whatever... and when I moved the actuall variables into the post script itself it worked fine. So it leads me to believe that includes are turned off and something is wrong with the SERVER['SELF'] thing..

Share this post


Link to post
Share on other sites
found something else..

if i do

<?

include("nav.php");

?>

i get a blank screen..

if i do

<?php

include("nav.php");

?>

i get what i need.. anyone know a way to disable that <?php thing so i can just do <?


and if i do something like.. have part of a php script at the top, end the <? ?> somewhere in the middle to display html without having to worry about echos and the reopen the php tags.. it messes up that page and display the rest of the php coding without parsing it

Share this post


Link to post
Share on other sites
It's a php.ini setting called short_open_tag, and it needs to be set to "on". However, I suggest you keep it "off", and get in the habit of using <?php, so your code will be compatible with all servers.

And judeddokoinu:[b] [/b]With short_open_tag set to "on", <?=$variable?> will echo the contents of $variable - it does the same as:

[code]<?php
echo $variable;
?>[/code]

However, some servers do not support that syntax (the ones with short_open_tag = off) and so you should avoid that way of echoing data.

Share this post


Link to post
Share on other sites

×

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.