Php Session issue? -
i have stored error message in session variable , gets displayed on page when condition becomes false. now, want on refreshing page message disappear , freeing session variable.
code : to show error message
<?php if (isset($_session['er'])): //showing errors on salary form ?> <div class="form-errors"> <?php foreach ($_session['er'] $mistake): ?> <p> <?php echo $mistake ?> </p> <?php endforeach ;?> </div> <?php endif; ?>
storing error
$_session['er'] = array("salary must between 10000 , 80000."); header("location:addsalary.php");
just unset right after printed error. shown once
<?php if (isset($_session['er'])): //showing errors on salary form ?> <div class="form-errors"> <?php foreach ($_session['er'] $mistake): ?> <p> <?php echo $mistake ?> </p> <?php endforeach ;?> </div> <?php unset($_session['er']); ?> <?php endif; ?>
Comments
Post a Comment