How can PHP be used to extract URL parameters for prefilling input fields?
To extract URL parameters in PHP for prefilling input fields, you can use the $_GET superglobal array. This array contains key-value pairs of parameters passed in the URL. You can then use these parameters to prefill input fields on a form by echoing the parameter values within the input field's value attribute.
<input type="text" name="username" value="<?php echo isset($_GET['username']) ? $_GET['username'] : ''; ?>">
<input type="email" name="email" value="<?php echo isset($_GET['email']) ? $_GET['email'] : ''; ?>">
<input type="password" name="password" value="">
Keywords
Related Questions
- How can pagination be implemented in PHP to limit the output of database records to 100 entries?
- What best practices should be followed when processing form data in PHP to handle different input scenarios?
- How can a client be reprogrammed to display the correct information from a PHP-generated playlist?