I have created a php script and saved it as script.php, located in the /var/www
directory. I also have index.html file which has a form which requires the user to enter a value and submit with the code
<html><body><form action="script.php" method="post">
name<input type="text name="fname"">
<input type="submit">
</form>
</body></html>
for testing purposes, i have set my script.php file to be like
<?php
echo "Could not read name";
?>
When i enter the url on the browser, i get the form and on clicking submit, it responds by saying the url http://localhost/script.php
was not found. i would like to know the reason why this is so. The question extends to why i can run the php script on its own when i move it from /var/www
to home folder and run it as php -f script.php
yet when i paste the url http://localhost/script.php
, it reports that the url has not been found
Best Answer
Hi this what I have done and I have got success with your Idea.
here this is what I have done ,
script.php
clickhere.html
I have placed that code with
sudo gedit
and written that code and saved at the location of/var/www/
.Then I have opened my browser ,and typed in my browser as
127.0.0.1/clickhere.html
then I have got it
and then I have clicked at that button