What is an easy code for a form in PHP?

How do i connect php form code to my website?

  • Hi I have made a website and have added a form to it but need to get it to work. I have got a php script for a form but dont know how to connect the form to the PHP code to get it to work?? also how do i test the code to make sure it works?? help

  • Answer:

    Usually you call it by putting the php file in the action attribute like this... <form action="myphpfile.php" method="post"> and just change myphpfile.php to the name and location of your php file that will process the form. you need a server with PHP installed on it to test it... you can download WAMP if you want to test it offline on your computer

Monty12 at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

1) You need WAMP to run PHP. Its server side not browser side. 2) Put your HTML form on 1 page and your PHP on another in the form opening tag in the action="" write the name of your php file. 3) To send form data to a file we use 1 of 2 methods GET or POST. Mainly POST. ------------------------------------- HTML FORM (form.php) ------------------------------------- <form method="post" action="form_process.php"> <input type="text" name="client_name" /> </form> ------------------------------------- The name="" is crucial this is how PHP knows what its pulling. Now the PHP script ------------------------------------- form_process.php ------------------------------------- <?php $client_name = $_POST['client_name']; echo $client_name; ?> ------------------------------------ PHP now has the form data and can display it as I have shown. You can now do what you want with the data submit it to a database perform other things to it. Good luck if you want further help get in touch.

Nik

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.