Jump to content


Photo

403 Forbidden Error when attempting to post


  • Please log in to reply
4 replies to this topic

#1 insrtsnhere13

insrtsnhere13
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 03 May 2006 - 08:42 PM

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:


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


#2 judeddokoinu

judeddokoinu
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 03 May 2006 - 11:29 PM

Not sure about the error, but you do have an extra "=" in this line:

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

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


#3 insrtsnhere13

insrtsnhere13
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 04 May 2006 - 12:28 AM

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

#4 insrtsnhere13

insrtsnhere13
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 04 May 2006 - 12:50 AM

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

#5 neylitalo

neylitalo
  • Staff Alumni
  • Advanced Member
  • 1,854 posts
  • LocationMichigan, USA

Posted 04 May 2006 - 02:28 AM

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: With short_open_tag set to "on", <?=$variable?> will echo the contents of $variable - it does the same as:

<?php
echo $variable;
?>

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.

http://nealylitalo.net - My personal website, and home of The Netizen's Journal.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users