Table of Content
PHP (a recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source scripting language that is especially suited for web development and can be easily embedded into HTML.
Rather than lots of commands to output HTML, PHP pages feature HTML with embedded code that does”something” (in this case, output “Hello, I am a PHP script!”). The PHP code is enclosed in the unique beginning and finish processing directions and ?> That lets you jump right into and out of “PHP mode”.
The good thing about PHP is that your form will look like exactly the same as an HTML5 form. You just need to know basic PHP code to start implementing it on your website forms.
What is a PHP form?
Among the most useful features of PHP is the way it handles HTML forms. The basic concept that’s important to know is that any form element will automatically be available to your PHP scripts. Here’s an HTML form with PHP:
Name: <input type="text" name="name" value="<?php echo $name;?>"> E-mail: <input type="text" name="email" value="<?php echo $email;?>"> Website: <input type="text" name="website" value="<?php echo $website;?>"> Comment: <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea> Gender: <input type="radio" name="gender" <?php if (isset($gender) && $gender=="female") echo "checked";?> value="female">Female <input type="radio" name="gender" <?php if (isset($gender) && $gender=="male") echo "checked";?> value="male">Male <input type="radio" name="gender" <?php if (isset($gender) && $gender=="other") echo "checked";?> value="other">Other
How do PHP forms work?
To demonstrate the values from the input fields after the user hits the submit button, then we add just a little PHP script within the value feature of the next input fields: name, email, and site. From the comment textarea area, we place the script involving the textarea and textarea tags. The tiny script outputs the value of this $name, $email, $site, and $remark factors.
Subsequently, we also ought to reveal which radio button which has been assessed. With this, we must control the assessed attribute (not the value characteristic for radio buttons).
If you navigate a little, you will find out there are a lot of examples of PHP forms. But just remind you that it will depend on your current website code.