scope - Global error message in php -
i have problem understanding of variable scopes.
i've got huge .php file many $_post validations (i know isn't not practise). anyways want little html-part above code outputs error message. message want change in every $_post validation function.
example:
if($err) { echo '<div class="error-message">'.$err.'</div>'; }
now functions following in same file.
if(isset($_post['test']) { $err = 'error!'; } if(isset($_post['test2'] { $err = 'error 2!'; }
but doesn't work. think there's huge missunderstanding , i'm ashamed. can me?
i didnt catch question maybe answer:
<body> <p id="error_message"> <?php if(isset($err)){echo $err;} ?> </p> </body>
and suggest learn how work sessions. , should know $_post empty on each refresh or f5
Comments
Post a Comment