I was wondering if there is a shorter way of writing the following code:
<input type="text" name="username" value="<?if(isset($_POST['username'])){ echo $_POST['username']; }?>" />
I hate having to do this will all my forms as the isset() check really messes up my HTML and scares away the frontenders.
you can make a helper:
function req($key, $default = '')
{
return isset($_REQUEST[$key]) ? $_REQUEST[$key] : $default;
}
<input name="user" value="<?php echo htmlentities(req('user')) ?>" />
@marvin's suggestion is nice for your script as well
regarding the front-end folks, i would say give them some basic php to use, like in this php for designers tutorial: http://www.digital-web.com/articles/php_for_designers/
learning the basic scrips i think is better than using an external templating system
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With