Jump to content

custom page available to only paid customer of a specific products


mysmallbizu

Recommended Posts

I have custom pages setup that only allow a paid customer of specific product login... This is limited to 1 page for each product.

 

What I'd like to do is update the customer page code so it allows users of multiple products login, For example if the have purchased produc1, product 3 or product 4 they would be able to login.

 

the code I'm using in the custom page php is and what I think I need is to update the $query to allow for multiple $PID items....

 

 

Here's what I have now.......

 

if ($_SESSION['uid']) {

$pid = 21;

$query = "SELECT packageid, domainstatus FROM tblhosting WHERE userid=".$_SESSION['uid']." AND packageid=".$pid;

$result = mysql_query($query);

$good = false;

while($row = mysql_fetch_array($result))

{

if ($row['domainstatus'] == "Active"){

$good = true;

}

 

}

} # To assign variables in Smarty use the following syntax.

# This can then be used as {$variablename} in the template

$smartyvalues["hasauth"] = $good;

 

# Define the template filename to be used without the .tpl extension

$templatefile = "mme";

 

outputClientArea($templatefile);

?>

 

 

Any help would be appreciated.

 

thanks

Link to comment
Share on other sites

simply modify your where clause :D

 

$packages = "1,2,5,19,31";

$query = "SELECT domainstatus DISTINCT FROM tblhosting WHERE userid=".$_SESSION['uid']." AND packageid IN (".$packages.")";

or

$query = "SELECT domainstatus DISTINCT FROM tblhosting WHERE userid='".$_SESSION['uid']."' AND packageid IN (".$packages.") AND domainstatus='Active'";

and check the record count ;)

Link to comment
Share on other sites

Thanks! I tried both just using a single product id using both of the queries you posted but neither of them worked with a single product ID

 

simply modify your where clause :D

 

$packages = "1,2,5,19,31";

$query = "SELECT domainstatus DISTINCT FROM tblhosting WHERE userid=".$_SESSION['uid']." AND packageid IN (".$packages.")";

or

$query = "SELECT domainstatus DISTINCT FROM tblhosting WHERE userid='".$_SESSION['uid']."' AND packageid IN (".$packages.") AND domainstatus='Active'";

and check the record count ;)

 

Any other suggestions or things to check?

Link to comment
Share on other sites

Run the query manually in mysql and see what it returns ..

if it returns valid data, you've typed it wrong in the code

if it returns an error, xis the error ;)

 

I ended up hard coding the pacakge ID's and it worked...

 

packageid IN ('1','3','7')

 

Thanks for your help... Now I have protected pages for individual product purchases!

Link to comment
Share on other sites

  • 3 months later...

I've got my pages protected now I need to add a little tweak!

 

I'd like to drip content from these pages... for example

 

week1page.php

week2page.php

week3page.php

week4page.php

 

Where the user would still have to login BUT their login would only work if they had been a paying member for

 

7 days

14 days

21 days

28 days

 

etc.

 

Any suggestions on how to code the sql query so that would work?

Link to comment
Share on other sites

Here's what I'm using now... that works for the select statement... I need help adding the date query

 

if ($_SESSION['uid']) {

 

$query = "SELECT packageid, domainstatus FROM tblhosting WHERE userid=".$_SESSION['uid']." AND packageid IN ('27','3','4','5','6','9','19','41','42','50','61','66','70','37')";

 

$result = mysql_query($query);

 

$good = false;

 

while($row = mysql_fetch_array($result))

 

{

 

if ($row['domainstatus'] == "Active"){

 

$good = true;

 

 

 

So I need help adding a select statement that selects a "regdate" plus a number of days from tblhosting.

 

This way I can add have a page for their reg date plus 7 days, for page 1 14 days for page 2 and so on.

 

I'm just hacking around, so if anyone has any ideas it would be greatly appreciated.

 

Thanks

Link to comment
Share on other sites

Sorry the title should read mySQL NOT msSQL

 

I need a little help tweaking this query that creates addon pages with dripped content for customers who have purchased a product via whmcs..

 

Here's what I'm using now... that works for the select statement... I need help adding the date query

 

if ($_SESSION['uid']) {

 

$query = "SELECT packageid, domainstatus FROM tblhosting WHERE userid=".$_SESSION['uid']." AND packageid IN ('27','3','4','5','6','9','19','41','42','50','61','66','70','37')";

 

$result = mysql_query($query);

 

$good = false;

 

while($row = mysql_fetch_array($result))

 

{

 

if ($row['domainstatus'] == "Active"){

 

$good = true;

 

 

 

So I need help adding a select statement that selects a "regdate" plus a number of days from tblhosting.

 

This way I can add have a page for their reg date plus 7 days, for page 1 14 days for page 2 and so on.

 

I'm just hacking around, so if anyone has any ideas it would be greatly appreciated.

 

Thanks

Edited by mysmallbizu
typo in title
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated