Zen Cart Logo

members only area

Locked

Views: 9,153

Results 21 to 34 of 34
This thread is locked. New replies are disabled.
19 Feb 2009, 8:51 PM
#21
ells avatar

ells

New Zenner

Join Date:
Nov 2008
Location:
Pacific Northwest
Posts:
24
Plugin Contributions:
0

members only area

I'm working on a similar update for my site except I'm using the customers group pricing id to determine who has access to what. Now I'm able to setup as many pricing groups as I want and customize various parts of the site depending on which group a customer belongs to.

This isn't fully implemented yet, but it seems functional. So let me know if you'd like more info.

20 Feb 2009, 8:54 AM
#22
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

Re: members only area

thanks Ells

this could well be of interest.

My implementation uses the define pages as they recognize the necessary php coding at the top of the page.

If you have similar coding for category/product/ezpages this could well prove very useful

best regards

Derek

6 Mar 2009, 1:18 PM
#23
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

Re: members only area

Members only Section – update – 6 March 2009

You are welcome to use these notes and programs for your own use at your own risk!!
If you can improve anything, that would be very welcome – please post on the forum.
Please backup all your files before any mods.

Use customers newsletter (char (1) field on database (customers)) to determine membership status 1 = member, 0 = non member
Set the newsletter field = 0 for all customers using program below
Set up membership category to purchase subscription
ClubBaitworks member - if subscribed manually set the newletter to subscribed using edit customer details (this sets the field to “1”)
For general email correspondence use the Tools/email option not newsletter.
Tools/newsletter to be used for members.

Configuration/Customer details set the show newsletter subscription to off, to remove option at customer account set up and ability of customer to edit his account details

Configuration/Email options remove unsubscribe link

This is a general program to send queries to the zencart (mysql) database

<!-- Program: mysql_send.php Desc: PHP program that sends an SQL query to the MySQL server and displays the results. --> <html> <head><title>SQL Query Sender</title></head> <body> <?php $host="localhost"; $user="username"; $password="password";

/* Section that executes query */
if(@$_GET['form'] == "yes")
{
mysql_connect($host,$user,$password);
mysql_select_db($_POST['database']);
$query = stripSlashes($_POST['query']);
$result = mysql_query($query);
echo "Database Selected: <b>{$_POST['database']}</b><br>
Query: <b>$query</b><h3>Results</h3><hr>";
if($result == 0)
{
echo "<b>Error ".mysql_errno().": ".mysql_error().
"</b>";
}
elseif (@mysql_num_rows($result) == 0)
{
echo("<b>Query completed. No results returned.
</b><br>");
}
else
{
echo "<table border='1'>
<thead>
<tr>";
for($i = 0;$i < mysql_num_fields($result);$i++)
{
echo "<th>".mysql_field_name($result,$i).
"</th>";
}
echo " </tr>
</thead>
<tbody>";
for ($i = 0; $i < mysql_num_rows($result); $i++)
{
echo "<tr>";
$row = mysql_fetch_row($result);
for($j = 0;$j<mysql_num_fields($result);$j++)
{
echo("<td>" . $row[$j] . "</td>");
}
echo "</tr>";
}
echo "</tbody>
</table>";
} //end else
echo "

<hr><br> <form action=\"{$_SERVER['PHP_SELF']}\" method=\"POST\"> <input type='hidden' name='query' value='$query'> <input type='hidden' name='database' value={$_POST['database']}> <input type='submit' name=\"queryButton\" value=\"New Query\"> <input type='submit' name=\"queryButton\" value=\"Edit Query\"> </form>"; unset($form); exit(); } // endif form=yes

/* Section that requests user input of query */
@$query=stripSlashes($_POST['query']);
if (@$_POST['queryButton'] != "Edit Query")
{
$query = " ";
}
?>

<form action="<?php echo $_SERVER['PHP_SELF'] ?>?form=yes" method="POST"> <table> <tr> <td align=right><b>Type in database name</b></td> <td><input type="text" name="database" value=<?php echo @$_POST['database'] ?> ></td> </tr> <tr> <td align="right" valign="top"> <b>Type in SQL query</b></td> <td><textarea name="query" cols="60" rows="10"><?php echo $query ?></textarea> </td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="Submit Query"></td> </tr> </table> </form> </body></html>

A typical query might be:
SELECT customers_firstname, customers_lastname, customers_id, customers_newsletter from customers

Which will display the database info in tabular form

Program to change newsletter status to zero on customers database

<!-- Program: newsletter field set.php Desc: PHP program that sets the newsletter field to 0 --> <html> <head><title>Newsletter set</title></head> <body> <?php $host="localhost"; $user="username"; $password="password"; $databasename = "databasename";

$connection = mysql_connect($host, $user, $password)
or die ("Could not connect to server");
$db = mysql_select_db($databasename,$connection)
or die ("Could not select derekbry_zen database");

$query = "update customers SET customers_newsletter = 0 WHERE customers_newsletter != 0";
$result = mysql_query($query)
or die ("Could not execute query");

echo "customers_newsletter field set to 0";
?>

</body> </html

The define pages are stored as .php files and are therefore used as the membership home page

To change define page names modify:

/zen/includes/languages/english/page_4.php

Line #22 : define('NAVBAR_TITLE', 'clubderek');

Line #23 : define('HEADING_TITLE', 'clubderek');

At the top of the define page used as the membership home page insert the following code:

<?php session_start(); $custID = $_SESSION['customer_id']; if ($custID == "") echo "<br>Please log in at the top of the screen to enter Club Baitworks<br> "; stop(); /* else { $host="localhost"; $user="username"; $password="password"; $database="databasename"; $connection = mysql_connect($host, $user, $password) or die ("Could not connect"); $db = mysql_select_db($database, $connection) or die ("Could not connect"); $query = "SELECT customers_firstname, customers_lastname, customers_id, customers_newsletter from customers WHERE customers_id=$custID"; $result = mysql_query($query) or die ("couldn't execute query"); $row = mysql_fetch_array($result,MYSQL_BOTH); $newlettercode = $row[3]; if ($newlettercode != 1) {echo "non ClubBaitworks member - please purchase membership subscription above at Club Baitworks"; stop(); } else { $_SESSION['auth'] = "YES"; /* echo "carry on to members section";*/ } } */ ?>

The html code for the members home page follows this php code

6 Mar 2009, 1:43 PM
#24
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: members only area

Derek, thanks for taking time to post further details/update.
:smile:

31 Mar 2009, 4:55 PM
#25
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

Re: members only area

Further update

We now have a members only section on our website, where visitors must have an account before they can enter the members section. This obviously builds up our email/marketing database.
A category was set up called Club Baitworks containing a simple navigation bar to the other member exclusive sections (using HTML).
Using the excellent download "Define Pages Generator" available from the download centre, all the individual pages for Club Baitworks were created with their appropriate names. We created a total of seven pages - I know of no limitation on this number.
The define pages are stored as .php files.
To stop people hacking into the members site, all the individual pages start with the following code which checks (a) whether they are signed in, (b) whether they have an account:

<?php session_start(); $custID = $_SESSION['customer_id']; if ($custID == "") { echo "<br>To enter Club Baitworks, either log in to your account with your existing username and password, <br> or create a new account using log in at the top of your screen<br> "; stop();} ?>

The rest of the HTML for the page follows after for each page.

If and when we want to charge for membership we will use the newsletter code to determine membership adding in the newsletter code check php as outlined in previous posts

31 Mar 2009, 5:04 PM
#26
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: members only area

Are you still using format outlined in your post number 23, dated 6th March 2009, of this thread? Thanks for posting updates BTW..

31 Mar 2009, 7:05 PM
#27
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

Re: members only area

Hi Misty

Not quite sure what you mean by Format.

The most recent thread I have posted is a stand alone simple solution for a members area branching off a standard category.

I understand that category pages and EZ pages are stored as text pages and therefore cannot interpret the php code needed at the top of each members page.

The define pages generator is a very fast way of generating the necessary (members) define pages.

If we decide to charge for membership, the "Program to change newsletter status to zero on customers database" will be used.
The php code to check newsletter field will then be added to the top of the define pages.

On one section of the members section we would like to have a "special offer" - is it possible to add in a zen cart shopping facility in the define page which will add to the shopping cart in the normal way?

Perhaps I ought to post that in another forum!
best regards

Derek

1 Apr 2009, 6:58 AM
#28
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: members only area

By format, meant coding...
shopping facility in define main page....
can only suggest you link to products that are hidden
unless exact url given to members...mod in download section
to hide categories/prods...
zencart gurus may be able to suggest different method/s..
HTH

20 Apr 2009, 7:57 PM
#29
liam1964 avatar

liam1964

New Zenner

Join Date:
Mar 2009
Location:
PA, USA
Posts:
31
Plugin Contributions:
0

Re: members only area

I have a similar requirement for my site.

I just want an area of my site that only people who are signed in can see. I want to offer technical support pages for the products I sell, but I want people to complete a registration form before they can see those pages.

The rest of my site, products and prices are available to anyone.

Does anyone know of a add-on or download that will help me do this? PLEASE be gentle, I am no expert!! :lamo:

24 Apr 2009, 7:53 AM
#30
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

Re: members only area

Hi Liam

are you familiar with using ftp software and modifying zen cart files with text editors?

cheers

Derek

24 Apr 2009, 11:22 AM
#31
liam1964 avatar

liam1964

New Zenner

Join Date:
Mar 2009
Location:
PA, USA
Posts:
31
Plugin Contributions:
0

Re: members only area

Derek Bryant:

Hi Liam

are you familiar with using ftp software and modifying zen cart files with text editors?

cheers

Derek

Hi Derek,
I had given in on a reply, stopped being lazy, and figured it out for myself. The answer I was looking for is already in this same thread, I guess my frustration at the time stopped my ability to read properly. Amazing how often that happens on this (and other) forums.

Thank you for whatever valuable information you were about to share.
Liam :bigups:

24 Apr 2009, 1:51 PM
#32
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

Re: members only area

Hi Liam

I presume you mean the my posting on 31st March 2009 (for anyone else struggling)

pleased you've cracked it!!:clap:

cheers

Derek

12 Sep 2009, 7:18 PM
#33
greengreetings avatar

greengreetings

Zen Follower

Join Date:
May 2009
Location:
Virginia
Posts:
90
Plugin Contributions:
0

Re: members only area

Derek Bryant:

This the code:

<?php $custID = $_SESSION['customer_id']; if ($custID > 0) { $host="localhost"; $user="username"; $password="password"; $database="database name"; $connection = mysql_connect($host, $user, $password) or die ("Could not connect"); $db = mysql_select_db($database, $connection) or die ("Could not connect"); $query = "SELECT customers_firstname, customers_lastname, customers_id, customers_newsletter from customers WHERE customers_id=$custID"; $result = mysql_query($query) or die ("couldn't execute query"); $row = mysql_fetch_array($result,MYSQL_BOTH); $newlettercode = $row[3]; if ($newlettercode == 0) {echo "non member - please purchase membership subscription above";} else {echo "link to members section";} } else { echo "<br>Please log in if you are a member<br> ";} ?>

**The code works great, Derek. I'm using it to encourage customers to create accounts as members to take part in contests. Here's the work in progress: ```
http://www.janaygreen.com/index.php?main_page=contests

14 Sep 2009, 3:50 PM
#34
derek_bryant avatar

derek_bryant

Zen Follower

Join Date:
Jul 2008
Location:
Bristol UK
Posts:
162
Plugin Contributions:
0

Re: members only area

Hi Greengreetings

thanks for the feedback - pleased to be of help

Derek:smile: