0

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!

4
Contributors
7
Replies
8
Views
8 Years
Discussion Span
Last Post by phpbeginners
0

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'>
0

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?

0

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!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.