sethupathy Posted June 18, 2007 Share Posted June 18, 2007 Hi guys i have a really long web form to make (its made) i am having problem with validation. what i would like to do is to put an * asterix at the end on the line of all unanswered questions can someone help i have seen this on other web form someone help thanks Quote Link to comment https://forums.phpfreaks.com/topic/56000-web-form-help/ Share on other sites More sharing options...
cooldude832 Posted June 18, 2007 Share Posted June 18, 2007 this sounds more like an application for javascript, however the best idea to handle this in php would be to initialze a testing scheme using regex pre loading the body. Place it in a function like this Function testvars { //Testing vars if (allpass) {$returnvar = "yes";} {else $returnvar = "no";} return $returnvar; } $test = testvars(); if ($test == "yes") { header(location:process.php) } else {//Load error box and set astriks} Quote Link to comment https://forums.phpfreaks.com/topic/56000-web-form-help/#findComment-276585 Share on other sites More sharing options...
teng84 Posted June 18, 2007 Share Posted June 18, 2007 if you can have those data that the user input then its not gonna be the prob but if it is its still a long journey any way your are what trying to say is upon submitting an u use php self ==== check all the data that is submitted and try the if condition <?if (!isset($_POST['your variable here'])) echo "*";?> <input name="" type="text" /> hope that helps Quote Link to comment https://forums.phpfreaks.com/topic/56000-web-form-help/#findComment-276586 Share on other sites More sharing options...
hackerkts Posted June 18, 2007 Share Posted June 18, 2007 <?php function check($form_name) { if ($_POST['submit']) { if (empty($_POST[$form_name])) { echo '*'; } } } ?> <form method="POST" action="<?=$_SERVER['PHP_SELF'];?>"> <input type="text" name="T1" size="20"><? check("T1"); ?><br> <input type="text" name="T2" size="20"><? check("T2"); ?><br> <input type="text" name="T3" size="20"><? check("T3"); ?><br> <input type="submit" value="Submit" name="submit"> </form> Hope this helps.. Quote Link to comment https://forums.phpfreaks.com/topic/56000-web-form-help/#findComment-276588 Share on other sites More sharing options...
cooldude832 Posted June 18, 2007 Share Posted June 18, 2007 is empty the new !ISSET? which is better? Quote Link to comment https://forums.phpfreaks.com/topic/56000-web-form-help/#findComment-276590 Share on other sites More sharing options...
hackerkts Posted June 18, 2007 Share Posted June 18, 2007 I don't think there's any different between it, empty means no variable pass on, and !isset mean the same thing. I prefer $_POST['form_name'] == '' same my time typing. Quote Link to comment https://forums.phpfreaks.com/topic/56000-web-form-help/#findComment-276591 Share on other sites More sharing options...
benjaminbeazy Posted June 18, 2007 Share Posted June 18, 2007 empty means variable is empty... the integer 0 is considered empty, as is "0" in a string isset checks if variable exists, including the values above $_POST['form_name'] == '' the problem with that is the user could still supply irrelevant information and pass that check, ie whitespace or any number of other things. Quote Link to comment https://forums.phpfreaks.com/topic/56000-web-form-help/#findComment-276593 Share on other sites More sharing options...
teng84 Posted June 18, 2007 Share Posted June 18, 2007 <?php $var = 0; // Evaluates to true because $var is empty if (empty($var)) { echo '$var is either 0, empty, or not set at all'; } // Evaluates as true because $var is set if (isset($var)) { echo '$var is set even though it is empty'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/56000-web-form-help/#findComment-276596 Share on other sites More sharing options...
cooldude832 Posted June 18, 2007 Share Posted June 18, 2007 just wondering because i had a talk with someone about php optimization and we aruged between echoes and switches from an optimization standpoint Quote Link to comment https://forums.phpfreaks.com/topic/56000-web-form-help/#findComment-276602 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.