1

How can I run php file using php’s built in web server But the php file is a form that will call another php file.

this is the php file that I am running using built in server

<!DOCTYPE html>
<html>
  <body>
   <p>this is to compute the Levenshtein distance</p>
   <form action="phpForm.php" target="_blank" method="POST">
    please enter the first string :<br>
    <input type="text" name="string1">
    <br>
    please enter the secondstring:<br>
    <input type="text" name="string2" >
    <br><br>
    <input type="submit" value="Submit">
   </form>
 </body>
</html>

when I submit, supposed to open phpForm.php thos is what I wrote in the command line

PHP -S localhost:8000 -t Sites/openSouq form.php

1 Answer 1

2

On the terminal or command line navigate to the directory that contains your PHP code and run:

php -S localhost:8080 -t ./

or

php -S localhost:8080 -t PATH_TO_PHP_FILES

Your mistake is you've ran php with the -t option that points to a specific file, when it should point to a directory. More information in the docs

Sign up to request clarification or add additional context in comments.

6 Comments

but in this case it will search for index.php file name that's why I have specified the name of the file
If you remove the form.php from the command can you access form.php in the address bar? You shouldn't need to specify the file name on the command line, just the root directory your PHP files reside in and then you can access the files by filename in the address bar.
If a URI request does not specify a file, then either index.php or index.html in the given directory are returned
That's correct. But why are you adding form.php to the end of the php command? That isn't required. If you remove that do you notice any changes?
I want to run the form.php that's why I am adding the name of the file to the command, I want to run form.php instead of index.php
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.