php - create an action based on specific database information -
update: not sure why answer removed. did receive solution , future views leaving original code below. make work needed change:
if (site_active == 0) to:
if ($row['site_active'] == 0) we removed "else exit;" code if site active page continue load normal. thank whoever posted answer. not sure why deleted because worked.
original question:
ok, using mysql database , php script. wanting make script checks whether user's site "active" or "disabled" code placed @ beginning of each webpage. if users website "active" website continue load normally. if users website "disabled" website redirect error page states so.
if client not pay monthly hosting fee set site "disabled" in database , site not accessible until payment made. return "active" state , accessible again. have came following code far (i new php if it's stupid don't judge please!) when code executed redirects page have set no matter rather displaying regular site. or suggestions make work appreciated!
<?php $con=mysqli_connect("connection info removed security reasons"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $result = mysqli_query($con,"select * mypanda_clients id='34'"); while($row = mysqli_fetch_array($result)) { if (site_active == 0) { header('location: http://www.green-panda.com/'); } else { exit; } } ?> <html> <h2>congratulations, site active!</h2> </html>
give try,
if ($row['site_active'] == 0) { ..... }
Comments
Post a Comment