omarisgod omarisgod - 1 year ago 66
MySQL Question

Redirect if Database has a certain value

Okay, so, the php page is already connected to the database.

Let's say we have a database, and within that database there is a table called Users.

The users table has two columns. Username and Voted.

I want a php query that says if "Username" has a "0" on Voted, it redirects them to a certain page. If voted has "1" it doesn't redirect them and they begin to go along with their day.

Answer Source

You can check if the username has 0 on voted by using SQL syntax

If, the condition is true use header() like:

$voted = // Get your value from database connection
if ($voted == 0) {
    header("Location: somewhere/page");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download