Hello, I'm using easyPHP to locally test some scripts I'm building, but I came across a problem that I can't seem to resolve. Within one of my PHP scripts, there's a segment where I end the PHP ( ?> ) and output a form in HTML, then resume the PHP section ( <?php ). The problem is, in this HTML segment, I have the following in the action value for the form tag:

<form method='post' action="<?=$_SERVER['PHP_SELF']?>">
    <!-- etc... -->

When the form is submitted and the page reloaded with the POST values, I just get the following error:

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

The URL bar has the address http://127.0.0.1/PHP Testing/<?=$_SERVER[PHP_SELF]?>.

I'm using Apache 2.2.13 with PHP 5.3.0 which all came with easyPHP 5.3.0. Can I assume that there are some values or permissions that I didn't set (possibly in php.ini)? And if so, how can I fix that? Any help would be appreciated, thanks!

What are you trying to do with the form and why?
Are you submitting a page to itself? If so, you wouldn't need to specify the action
i.e. you can just do

<form method='post'>

Yes, I was just submitting the form data to the same page. But I'm just confused now because I'm wondering if the <?= ... ?> format works, because upon submission, I have another HTML segment to output some info, along with the statement:

<p>Your email is <?=$_POST['newemail']?>.</p>

Which should output the newemail variable stored from the POST action, but it outputs a blank. Within a PHP segment though, if I do echo $_POST['newemail']; , it displays the email stored as newemail.

Any suggestions?

I've never seen the <?= ... ?> syntax before. I would stick to using echo.

<?=...?> is short-hand syntax for echoing data to a page. I personally don't use it, but its pretty common.

edit your php.ini file


find this "short_open_tag = On" default is Off so turn it on.

edit your php.ini file

find this "short_open_tag = On" default is Off so turn it on.

Thank you so much, that was the problem!

don't mention it :-)

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.