Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8518115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:53:36+00:00 2026-06-11T05:53:36+00:00

On my website I have a page that can only be viewed if the

  • 0

On my website I have a page that can only be viewed if the persons details are in a table called Members, the values are posted from a form in the previous page. This is the original code I had and it worked fine:

$query = "SELECT * FROM Members WHERE firstname='" . $firstname . "' and surname='" . 
$surname. "'"; 
$result = mysql_query($query);
$rows = mysql_num_rows($result);

if ($rows == 1) 
{ 
   //user continues loading page
} 
else 
{ 
   header ('location: signup.html'); //user is redirected to sign up page 
}

After some changes to the site, I now require the same user to have to have paid=’TRUE’ in the Members table to continue loading the page. This is the code I came up with:

$query = "SELECT * FROM Members WHERE firstname='" . $firstname . "' and surname='" . 
$surname. "'"; 
$result = mysql_query($query);
$rows = mysql_num_rows($result);

$query = "SELECT paid FROM Members WHERE firstname='" . $firstname . "' and surname='" . 
$surname. "'"; 
$result = mysql_query($query);
$paid = mysql_num_rows($result);


if ($rows == 1 && $paid=='TRUE') 
{ 
   //user continues loading page
} 
else 
{ 
   header ('location: signup.html'); //user is redirected to sign up page 
 }

With this new code, even if the user has paid it re-directs them to the signup page… Have I gone about this the wrong way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:53:38+00:00Added an answer on June 11, 2026 at 5:53 am

    You check $paid against ‘TRUE’ but fill it with mysql_num_rows.
    Try:

    if ($rows > 0  && $paid >0 )
    

    instead.

    Plus, since I can not see if you escape your strings properly, please take note that $firstname and $surname should be escaped/verified.

    Anyway you can skip the second mysql_query and use:

        $query = "SELECT * FROM Members WHERE firstname='" . $firstname . "' and surname='" . 
        $surname. "'"; 
        $result = mysql_query($query);
        $rows = mysql_num_rows($result);
        if( $rows ){
    
        $row = mysql_fetch_assoc($result);
            if($row['paid'] =='TRUE') {
                //continue
            } else {
        //redirect
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am porting over a website from asp. i have one page that i
I have a page that displays various fields from a mysql_query. I only want
My website should have some parts that can only be seen when the user
i have a website page that contains only data of which one field gives
I have a website that does not have page refreshes when the visitor navigates
I have a single page website that changes content based on variables passed through
I have a page on a website that contains a secure form inside an
I have a website that has products list page and product detail page .
I have a website that requires a very large background image. The page loads
Given a website site has different web pages that can only be accessed by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.