Page 2 of 2
Re: Apache not interpreting in some circumstances
Posted: Wed Apr 20, 2011 8:41 pm
by incubi
Hi,
The print statement like the one I posted needs to be in the php tags i.e. <?php and ?>
It will print the HTML form and action line which is part of the HTML form that you tried to create.
The $_SERVER['PHP_SELF'] will pick up the path and script file so you don't need to deal with putting in the Action path by hand.
Also, if you could let us see all the code both HTML and PHP in the one, two or however many files there are. Its hard to understand what is going on with just snips of the code. You can blank out what you can't show us. This way we can look and the HTML and the PHP all together.
The question that McInfo posted is spot on so be sure you try what he said and show the results.
And most important clear the PHP and Apache error logs then run your program and post the log results if there are any. Again you can block parts we should not see.
Thanks
Lee
Re: Apache not interpreting in some circumstances
Posted: Thu Apr 21, 2011 3:23 am
by Simbachips
First the code I used, it is all in one file to make things easier, called dd.php
Code: Select all
<html>
<body>
<?php
if(isset($_POST['submit']))
{
$name = $_POST['name'];
echo "User Has submitted the form and entered this name : <b> $name </b>";
}
?>
<form method="post" action="<?php print $_SERVER['PHP_SELF'] ?>" >
Name: <input type="text" name="name" />
<input type="submit"/>
</form>
</body>
</html>
Nothing happens the page flickers and the input remains on screen... Name:
Below is the apache error log:
[Thu Apr 21 17:37:13 2011] [error] [client 127.0.0.1] File does not exist: C:/xampp/htdocs/Code2/'.$_SERVER['PHP_SELF'].', referer: //localhost/Code2/dd.php
I cannot seem to find where php log files are so I went to php.ini and error_log = "C:\php_error.log"
This did not work, I then uncommented ---> error_log = syslog
Nothing came up in event viewer
it was initially set to this error_log = php_errors.log
Also I updated my previous post hopefully now it makes more sense, did I answer mcinfo's question?
Re: Apache not interpreting in some circumstances
Posted: Thu Apr 21, 2011 4:19 am
by Simbachips
I will be heading off for a few days so I wont reply until Monday next week. I am still very keen to get this sorted... please still reply as I will check in on the thread periodically until I leave otherwise I will reply when I get back.
Again thanks all and good holiday.
Re: Apache not interpreting in some circumstances
Posted: Thu Apr 21, 2011 9:41 am
by incubi
Hi, sorry didn't see that was all the code there was. Please clear the log again and delete everything in your dd.php file then put in the following code and try again and post the results.
Code: Select all
<?php
print '<html><body>';
if(isset($_POST['Update']))
{
$name = $_POST['name'];
echo "User Has submitted the form and entered this name : <b> $name </b>";
}
print '<FORM NAME="form1" ACTION="'.$_SERVER['PHP_SELF'].'" METHOD="POST">';
print 'Name: <input type="text" name="name" value="">';
print '<INPUT TYPE="submit" NAME="Update" VALUE="Update">';
print '</form></body></html>';
?>
Thanks
Lee
Re: Apache not interpreting in some circumstances
Posted: Thu Apr 21, 2011 10:28 am
by incubi
I was able to reproduce your error on my system using the code I posted. I remove my php mod from the Apache config file so Apache could not understand php when I did I got this error
File does not exist: C:/htdocs/'.$_SERVER['PHP_SELF'].', referer:
http://localhost/test.php
I would say you need to start looking at your Apache config. I don't know the version you have but if its 2.x then you need to be sure these lines is in the httpd.conf file
PHPIniDir "R:/Program Files/PHP/"
LoadModule php5_module "R:/Program Files/PHP/php5apache2_2.dll"
and that you have the index.php in your DirectoryIndex
Lee
Re: Apache not interpreting in some circumstances
Posted: Mon Apr 25, 2011 9:02 pm
by Simbachips
Incubi, the code worked that you gave. It updated saying User Has submitted the form and entered this name : Steve.
However the standard html form with the corresponding php file still did not work.
Below is what I have in my httpd.conf:
LoadModule "C:\xampp\php\php5apache2_2.dll"
<IfModule dir_module>
DirectoryIndex index.php index.pl index.cgi index.asp and so on, refer to one of my earlier posts for full list.
I could not find PHPIniDir "R:/Program Files/PHP/", Where would that go?
So to reiterate the code you provided worked like an atomic clock, but the usual welcome.php and form did not.
Re: Apache not interpreting in some circumstances
Posted: Mon Apr 25, 2011 10:52 pm
by incubi
Hi Simbachips welcome back, no pun intended
I must have gotten off track then. If the form code I posted worked for you and
the original form code welcome.php didn't then why not build off the good code to get the form you need?
I guess I'm saying if the code I sent you worked then you don't have an Apache or PHP problem you have a code problem.
Lee
Re: Apache not interpreting in some circumstances
Posted: Mon Apr 25, 2011 11:57 pm
by Simbachips
None taken, anyway you seem to be the only one still replying, I might just keep at it for a bit longer and stop pestering you.
Thanks for the help.