pyeastinsnym
New Member
UPDATE: Not sure why the answer was removed. But i did receive a solution and for future views I am leaving the original code below. But to make this work we simply needed to change: \[code\]if (site_active == 0)\[/code\]TO: \[code\]if ($row['site_active'] == 0) \[/code\]We also removed the "else exit;" code so if the site was active the page would continue to load like normal. Thank you to whoever posted this answer. Not sure why you deleted it because it worked.Original Question:Ok, I am using MYSQL as a database and then php for my script. I am wanting to make a script that checks whether a user's site is "active" or "disabled" this code will be placed at the beginning of each webpage. If the users website is "active" then the website will continue to load normally. If the users website is "disabled" then the website will redirect to an error page that states so. If my client does not pay the monthly hosting fee then I will set the site to "disabled" in the database and the site will not be accessible until the payment is made. which then I will return it to an "active" state and it will be accessible again. I have came up with the following code so far (I am new to php so if it's stupid don't judge please!) When this code is executed it redirects to the page I have set no matter what rather than displaying the regular site. Any help or suggestions to make this work would be greatly appreciated!\[code\] <?php$con=mysqli_connect("CONNECTION INFO REMOVED FOR SECURITY REASONS");// Check connectionif (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); }$result = mysqli_query($con,"SELECT * FROM mypanda_clientsWHERE id='34'");while($row = mysqli_fetch_array($result)) { if (site_active == 0) { header('Location: http://www.green-panda.com/'); } else { exit; } }?><html> <h2>Congratulations, your site is active!</h2> </html>\[/code\]