PDA

View Full Version : tweaking vSignup script


cooc
08-21-2004, 09:37 AM
Hi! :)

Can someone please help?
i need to make a page that will do a search in the vSignup script:
http://www.beanbug.net/Scripts/vSignup_2.1.zip
a search that will search & show user emails by entering their zip code...
so it will show a list of emails under a certain zip code that is entered.

the same thing with the country (so it will show a list of emails
under a certain country that is entered to the search field.)
i hope you can help.
thank you so much :cool:

cooc
08-22-2004, 11:37 AM
please????

raf
08-22-2004, 11:53 AM
maybe ask a more punctual question about some code you already have ...

cooc
08-22-2004, 12:05 PM
maybe ask a more punctual question about some code you already have ...
well, hmmm,
the entire code is in the above link.
i just need a small html page with a form [that will call to a php page] & do a search [as i specified above] in all the verified users... [that clicked the confirmation email].

hmm, maybe this will help - the structure of the DB:



# File: createdb.sql
# Script Name: vSignup 2.1
# Author: Vincent Ryan Ong
#
# Description:
# vSignup is a member registration script which utilizes vAuthenticate
# for its security handling. This handy script features email verification,
# sending confirmation email message, restricting email domains that are
# allowed for membership, and much more.
#
# This script is a freeware but if you want to give donations,
# please send your checks (coz cash will probably be stolen in the
# post office) them to:
#
# Vincent Ryan Ong
# Rm. 440 Wellington Bldg.
# 655 Condesa St. Binondo, Manila
# Philippines, 1006

#
# AUTHUSER
#

CREATE TABLE authuser (
id int(11) NOT NULL auto_increment,
uname varchar(25) NOT NULL default '',
passwd varchar(25) NOT NULL default '',
team varchar(25) NOT NULL default '',
level int(4) NOT NULL default '0',
status varchar(10) NOT NULL default '',
lastlogin datetime default NULL,
logincount int(11) default NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;

#
# Dumping data for table 'authuser'
#

INSERT INTO authuser VALUES ( '1', 'sa', '', 'Admin', '1', 'active', '', 0);
INSERT INTO authuser VALUES ( '2', 'admin', '', 'Admin', '1', 'active', '', 0);
INSERT INTO authuser VALUES ( '3', 'test', 'test', 'Temporary', '999', 'active', '', 0);


#
# AUTHTEAM
#

CREATE TABLE authteam (
id int(4) NOT NULL auto_increment,
teamname varchar(25) NOT NULL,
teamlead varchar(25) NOT NULL,
status varchar(10) NOT NULL,
PRIMARY KEY (id),
KEY teamname (teamname, teamlead)
);

#
# Dumping data for table 'authteam'
#

INSERT INTO authteam VALUES ( '1', 'Ungrouped', 'sa', 'active');
INSERT INTO authteam VALUES ( '2', 'Admin', 'sa', 'active');
INSERT INTO authteam VALUES ( '3', 'Temporary', 'sa', 'active');

#
# Table structure for table `signup`
#

CREATE TABLE signup (
id int(11) NOT NULL auto_increment,
uname varchar(25) NOT NULL default '',
fname varchar(30) NOT NULL default '',
lname varchar(20) NOT NULL default '',
email varchar(45) NOT NULL default '',
country varchar(20) default NULL,
zipcode bigint(20) default NULL,
datejoined datetime NOT NULL default '0000-00-00 00:00:00',
confirmkey varchar(32) NOT NULL default '',
PRIMARY KEY (id)
) TYPE=MyISAM;

#
# Dumping data for table `signup`
#

# --------------------------------------------------------

#
# Table structure for table `emailer`
#

CREATE TABLE emailer (
id int(11) NOT NULL auto_increment,
profile varchar(20) NOT NULL default '',
email varchar(40) NOT NULL default '',
name varchar(50) NOT NULL default '',
subject varchar(100) NOT NULL default '',
emailmessage text NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY id (id,profile),
KEY profile (profile)
) TYPE=MyISAM;

#
# Dumping data for table `emailer`
#

INSERT INTO emailer VALUES (2, 'Default', 'membership@domain.com', 'Membership', 'Your Membership Confirmation', 'Hi!\r\n\r\nPlease click [[<-here->]] to confirm your membership. If your email client does not support HTML messages, open a new browser then copy this URL ([[--]]) and paste it in the location bar. \r\n\r\nRegards,\r\nMembership Department');
INSERT INTO emailer VALUES (5, 'Password Reminder', 'membership@domain.com', 'Membership', 'Your Password Reminder', 'Hello!\r\n\r\nYou have recently requested to have your password emailed to this address. \r\n\r\nYour password is: [[--]]\r\n\r\nIf you think that you did not request for this info, please disregard this message and accept our apologies for taking your time.\r\n\r\nThank you and good day!\r\n\r\nSincerely,\r\nMembership Department');
# --------------------------------------------------------

#
# Table structure for table `signupsetup`
#

CREATE TABLE signupsetup (
id int(11) NOT NULL auto_increment,
validemail text,
profile varchar(20) NOT NULL default '',
autoapprove tinyint(4) NOT NULL default '0',
autosend tinyint(4) NOT NULL default '0',
autosendadmin tinyint(4) NOT NULL default '0',
PRIMARY KEY (id),
UNIQUE KEY id (id)
) TYPE=MyISAM;

#
# Dumping data for table `signupsetup`
#

INSERT INTO signupsetup VALUES (1, '', 'Default', 0, 1, 0);




thanks

cooc
08-23-2004, 11:58 AM
ok, maybe this will help:
there is a table named authuser in the DB, inside that table there is a row called uname some other rows... & a row called status. in that row you have values of inactive or active [for users that confirmed the registration email or not]

there is another table in the DB called signup. in that table you have all the users that were on the authuser table, confirmed or not (active AND inactive]. the rows there are: uname fname lname email country zipcode

so... the search page should look for users under the zipcode that was entered to the search field, check if they are active [confirmed the registration email] & show a list of emails of all the users under that zip code.
same thing with the country... thats all. :)

thanks

raf
08-23-2004, 12:39 PM
you don't need to help us. you are asking for help.

most of the people that read your thread have written such searchfeature hundreds of times. but this isn't a 'free code on demand' forum where you can just post your requirements and where someone will then write it out for you.
you need to write out as much of the code as you can, and if you then have punctual questions (like how to write the query or so), then you can post them here and they will be answered within the hour

since none of the nearly 100 views gets you any code, i think the message is: get your hands dirty and start writing the code to see how far you get.
there are some excellent tutorials over at www.hotscripts.com on elementaty formprocessing and db-interactions with all popular server side scriptinglanguages (i assume you'll want ASP or PHP?)

me personally, i wount write it out since if you don't even know enough html to write a form, then i'm quite sure (based on previous bad experiences) that even if i write it out, there is a big chance that you'd not be capable to fit in in and get it working on your site.

cooc
08-23-2004, 01:23 PM
you don't need to help us. you are asking for help.
hey raf,
yes, i'm the one that need help, i just wanted to say that i want to help you help me... :)

most of the people that read your thread have written such searchfeature hundreds of times. but this isn't a 'free code on demand' forum where you can just post your requirements and where someone will then write it out for you.
you need to write out as much of the code as you can, and if you then have punctual questions (like how to write the query or so), then you can post them here and they will be answered within the hour

since none of the nearly 100 views gets you any code, i think the message is: get your hands dirty and start writing the code to see how far you get.
there are some excellent tutorials over at www.hotscripts.com on elementaty formprocessing and db-interactions with all popular server side scriptinglanguages (i assume you'll want ASP or PHP?)

me personally, i wount write it out since if you don't even know enough html to write a form, then i'm quite sure (based on previous bad experiences) that even if i write it out, there is a big chance that you'd not be capable to fit in in and get it working on your site.

i do know html very good,
i just don't know php/mysql...
the form page should look exactly like that:

<html>

<form name="search" method="post" action="search.php">

<input type="text" name="zipcode" VALUE="Enter zipcode" onFocus="if(this.value=='Enter zipcode')this.value='';" size="20" />

<INPUT TYPE="SUBMIT" NAME="SendButton" VALUE="Search">

</form>

</html>


so you see, i know a thing or 2...
i also know how to mess with the DB...
it's the search.php that i'm after... :)
& belive me that once someone will help, i'll know what to do with it :thumbsup:

cooc
08-23-2004, 02:15 PM
hmm, i tried to do a basic php page that will just show the email of a member:



<?php

//i opened a connection to the DB
$db="MY-DB";
$link = mysql_connect("localhost", "MY-USER");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());

//basic search to show the email of a member under the signup table
$selection = mysql_query("select email from signup where uname='lllllk'");
{echo $selection ;
}


mysql_close();
?>



what i saw on screen was:
Resource id #7
why it didn't show me the actual email data?

raf
08-23-2004, 02:39 PM
you missed a concatinating . at line 14
this is the most basic lookupcode

<?php
//i opened a connection to the DB --> the connectiostrings should be in a seperate file that you then just include
$link = mysql_connect('localhost', 'MY-USER') or die ('Could not connect to MySQL'); // no password?
mysql_select_db('MY-DB-HERE' , $link) or die('Could not open db'); // it's unsafe to echo the dbname or mysql_error()

//basic search to show all emails under signup table
$selection = mysql_query("SELECT email FROM signup WHERE zipcode=" . addslashes(trim($_POST['zipcode']))) or die ('Queryproblem');
if (mysql_num_rows($selection)>= 1){
echo '<ul>';
while ($row = mysql_fetch_assoc($selection) ) {
echo '<li>' . $row['email'] . '</li>';
}
echo '</ul>';
}else{
echo 'No emails for this zipcode.';
}
mysql_close();// you don't realy need to close the connection
?>


if required, then you need to add some extra checks to see if the submitbutton was hit, if the zipcode isn't empty, if it is numeric etc.
you also maybe wan't to combine the zipcode with other variales inside your condition. (can be posted values or hardcoded ones)

Just post back if you need more info or get stuck trying to expand the code.

cooc
08-23-2004, 03:03 PM
your tweaked code:


<?php
//i opened a connection to the DB
$link = mysql_connect('localhost', 'USER') or die ('Could not connect to MySQL');
mysql_select_db('MY-DB' , $link) or die('Could not open db');

//basic search to show all emails under signup table
$selection = mysql_query("SELECT email FROM signup WHERE zipcode=" . addslashes(trim($_POST['zipcode']))) or die ('Queryproblem');
if (mysql_num_rows($selection)>= 1){
echo '<ul>';
while ($row = mysql_fetch_assoc($selection) ) {
echo '<li>' . $row['email'] . '</li>';
}
echo '</ul>';
}else{
echo 'No emails for this zipcode.';
}
mysql_close();
?>



(yes, no pass...)
well, anyway, i get:
Queryproblem
i know... i might did somthing stupid... :rolleyes:
oh, & what is $_POST for?

raf
08-23-2004, 03:12 PM
$_POST if the formcollection after the form is posted.

$_POST['variable'] will contain the value of the formfield with name="variable"


echo out the query and error like this

$sql = "SELECT email FROM signup WHERE zipcode=" . addslashes(trim($_POST['zipcode']));
$selection = mysql_query($sql) or die ('Queryproblem: used query' . $sql . '<br />error:' . mysql_error());

and then look in your browser what is printed for the query and errormessage

cooc
08-23-2004, 03:29 PM
it's working, it's working, it's showing me list of emails under a typed zipcode...
cool :thumbsup:
ok, now why should i check to see if the submitbutton was hit?
about the empty field - i tried it - it say Queryproblem... thats ok...
well, now i only need it to check if the user is an *activated user, if not then it should not echo that users email...


*activated user:
there is a table named authuser in the DB, inside that table there is a row called uname some other rows... & a row called status. in that row you have values of inactive or active [for users that confirmed the registration email or not]


thanks man :D

cooc
08-23-2004, 03:58 PM
i checked the search form,
if i'm entering a number bigger than 20 chars to the search field, it giving me some email from the DB...
i guess that because that the zipcode row can be just 20 chars, if the number i'm entering is bigger - things get messy... hmmm...
yes, i can add maxlength="20" to the form... but hackers can still bypass that, no? (the can make a simple html page without the maxlength="20")
any ideas?
thx

raf
08-23-2004, 04:38 PM
To check if the form was submitted:

if ($_POST['SendButton'] == 'Search'){
}

to check if the posted value is numeric and between 1 and 20 numbers:
if (ereg('[0-9]{1,20}', $_POST['zipcode'])){
}

so your code could be

if ($_POST['SendButton'] == 'Search'){
if (ereg('[0-9]{1,20}', $_POST['zipcode'])){
//your current code
}else{
echo 'Invalid value. Zipcode needs to be between 1 and 20 digits.';
}
}else{
echo 'Invalid pagerequest.';
}


about the authenticated value in the other table : you need to join both tables. Are there joined fields in these two tables? a userID or so that is stored in both tables?

cooc
08-23-2004, 05:01 PM
so it should look like that?

.
.
.
$selection = mysql_query("SELECT email FROM signup WHERE zipcode=" . addslashes(trim($_POST['zipcode']))) or die ('Queryproblem');
if ($_POST['SendButton'] == 'Search'){
if (ereg('[0-9]{1,20}', $_POST['zipcode'])){
if (mysql_num_rows($selection)>= 1){
echo '<ul>';
while ($row = mysql_fetch_assoc($selection) ) {
echo '<li>' . $row['email'] . '</li>';
}
echo '</ul>';
}else{
echo 'No emails for this member number.';
}
}else{
echo 'Invalid value. Zipcode needs to be between 1 and 20 digits.';
}
}else{
echo 'Invalid pagerequest.';
}

mysql_close();






& no, there are no joined fields...

raf
08-23-2004, 06:40 PM
No. Code should be

if ($_POST['SendButton'] == 'Search'){
if (ereg('[0-9]{1,20}', $_POST['zipcode'])){
$selection = mysql_query("SELECT email FROM signup WHERE zipcode=" . addslashes(trim($_POST['zipcode']))) or die ('Queryproblem');
if (mysql_num_rows($selection)>= 1){
echo '<ul>';
while ($row = mysql_fetch_assoc($selection) ) {
echo '<li>' . $row['email'] . '</li>';
}
echo '</ul>';
}else{
echo 'No emails for this zipcode.';
}
}else{
echo 'Invalid value. Zipcode needs to be between 1 and 20 digits.';
}
}else{
echo 'Invalid pagerequest.';
}


if ypu can't join the tables, then there is no bulletproof way to do this. joining on varchars is not a good idea.
i don't quite see why you have two tables. why don't you merge them into one table, since they both just contain a few descriptive data about the users.

cooc
08-23-2004, 07:09 PM
hmm, i tried to fool the code,
i gave it random numbers, & it keep giving me that email addres as a search result...

... about the merge, i can't merge them... this is how this acript is made...

cooc
08-23-2004, 07:28 PM
ok,ok, the problem is that you can't register with a username not in english...
so i just need to restrict this when users are registering to give permission for a-z 0-1 with no special chars like $$%%#$% or other languages letters [no hebrew, arabian... etc... letters]
it's ok now.

i'm trying to do the same page just that search under country, what is wrong:

.
.
.
if ($_POST['SendButton'] == 'Search'){
if (ereg('[0-9,a-b,A-B]{1,20}', $_POST['country'])){
$selection = mysql_query("SELECT email FROM signup WHERE country=" . addslashes(trim($_POST['country']))) or die ('Queryproblem');
if (mysql_num_rows($selection)>= 1){
echo '<ul>';
while ($row = mysql_fetch_assoc($selection) ) {
echo '<li>' . $row['email'] . '</li>';
}
echo '</ul>';
}else{
echo 'No emails for this country.';
}
}else{
echo 'Invalid value. country needs to be between 1 and 20 digits.';
}
}else{
echo 'Invalid pagerequest.';
}
mysql_close();
?>


oh, & yes i want country to be chars 0-9 a-b A-B

raf
08-23-2004, 09:05 PM
[0-9,a-b,A-B]
needs to be
[0-9a-zA-Z]

cooc
08-23-2004, 09:42 PM
hmmm, it doesn't work.
i tried the simple code:


$selection = mysql_query("SELECT email FROM signup WHERE country=" . addslashes(trim($_POST['country']))) or die ('Queryproblem');
if (mysql_num_rows($selection)>= 1){
echo '<ul>';
while ($row = mysql_fetch_assoc($selection) ) {
echo '<li>' . $row['email'] . '</li>';
}
echo '</ul>';
}else{
echo 'No emails for this country.';
}
mysql_close();
?>



i registered as a user under country test6
then i searched for users email under country test 6 & got Queryproblem
i can't see anything wrong in the code...

raf
08-23-2004, 09:45 PM
country is probably a stringcolumn, so the values need to be enclosed in quotes. like

$selection = mysql_query("SELECT email FROM signup WHERE country='" . addslashes(trim($_POST['country'])) ."'") or die ('Queryproblem');

cooc
08-23-2004, 10:12 PM
ok, cool!
the thing is - there are users from several countries, that uses their own languages in the country field, so the country is tranlated into some html code/ascii code or whatever [i attached a screenshot] & when they enter it, nothing is found... [you have to enter this code if you want to find it...]

raf
08-23-2004, 10:32 PM
i don't quit understand the problem.

just have them type in whatever language they use, and then do the same conversion as you do before storing the value in the db...

cooc
08-23-2004, 10:44 PM
but i'm not doing any conversion... it just happens...

raf
08-23-2004, 10:49 PM
how does the value gets into the db? is it inserted through a form + php?

cooc
08-23-2004, 10:57 PM
there is a form page [php] that insert the data to mysql...

raf
08-24-2004, 12:08 AM
so ... get the relevant code from the page that processes that form so that we can see which encoding takes place + where.

cooc
08-24-2004, 10:11 AM
this page process the data from the registration form:


<?
/*
# File: chgpwd.php
# Script Name: vSignup 2.1
# Author: Vincent Ryan Ong
#
# Description:
# vSignup is a member registration script which utilizes vAuthenticate
# for its security handling. This handy script features email verification,
# sending confirmation email message, restricting email domains that are
# allowed for membership, and much more.
#
# This script is a freeware but if you want to give donations,
# please send your checks (coz cash will probably be stolen in the
# post office) them to:
#
# Vincent Ryan Ong
# Rm. 440 Wellington Bldg.
# 655 Condesa St. Binondo, Manila
# Philippines, 1006
*/
?>
<? require ("signupconfig.php"); ?>
<html>
<head>
<title>vSignup 2.1</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">

<?
include ("auth.php");
$connection = mysql_connect($dbhost, $dbusername, $dbpassword);
$db = mysql_select_db($dbname);

// PASSWORD REMINDER
if ($remind)
{
$qReminder = mysql_query("SELECT * FROM signup WHERE uname='$username'");
$RemindRow = mysql_fetch_array($qReminder);
$numrows = mysql_num_rows($qReminder);

$qEmailer = mysql_query("SELECT * FROM emailer WHERE profile='Password Reminder'");
$EmailerRow = mysql_fetch_array($qEmailer);

$qPassword = mysql_query("SELECT * FROM authuser WHERE uname='$username'");
$PasswordRow = mysql_fetch_array($qPassword);

if (mysql_num_rows($qReminder) == 0)
{
include ("pwdremind.php");
print "<font face=\"Verdana\" size=\"2\" color=\"#FF0000\">";
print " <b>The user does not have a record in our database.</b>";
print "</font>";
exit;
}
else
{
// Get values for emailer
$name = $EmailerRow["name"];
$email = $EmailerRow["email"];
$subject = $EmailerRow["subject"];

// Insert HTML line breaks for newlines in $ReminderMessage
// FIND A BETTER WAY FOR THIS. WE SHOULD AVOID USING HTML TAGS FOR EMAIL
// BECAUSE NOT ALL CLIENTS SUPPORT HTML IN EMAIL MESSAGES
$ReminderMessage = $EmailerRow["emailmessage"];

// Replace occurances of [[--]] in template
$ReminderMessage = str_replace ("[[--]]", $PasswordRow["passwd"], $ReminderMessage);

$sent = @mail($RemindRow["email"], $subject, $ReminderMessage, "From:$name<$email>\nReply-to:$email");

if ($sent)
{
print "<font face=\"Verdana\" size=\"2\" color=\"#FF0000\">";
print " <b>The email has been sent to the email address you've specified during the signup process.</b>";
print " <p>&nbsp;</p>";
print "</font>";
include ("login.php");
}

exit;
}
} // END - PASSWORD REMINDER

// SIGNUP SETTINGS
$qSetup = mysql_query("SELECT * FROM signupsetup");
$SetupRow = mysql_fetch_array($qSetup);
$ValidEmailDomains = $SetupRow["validemail"];
$profile = $SetupRow["profile"];
$AutoApprove = $SetupRow["autoapprove"];
$AutoSend = $SetupRow["autosend"];
$AutoSendAdmin = $SetupRow["autosendadmin"];

// EMAILER SETTINGS
$qEmailer = mysql_query("SELECT * FROM emailer WHERE profile='$profile'");
$EmailerRow = mysql_fetch_array($qEmailer);
$EmailerName = $EmailerRow["name"];
$EmailerFrom = $EmailerRow["email"];
$EmailerSubject = $EmailerRow["subject"];
$EmailerMessage = $EmailerRow["emailmessage"];

// SIGNUP FORM PROCESSING
$EmailQuery = mysql_query("SELECT * FROM signup WHERE email='$email'");
$email = strtolower($email);
$EmailExist = mysql_num_rows($EmailQuery); // Returns 0 if not yet existing
$username = strtolower($username);
$UsernameQuery = mysql_query ("SELECT * FROM signup WHERE uname='$username'");
$UsernameExist = mysql_num_rows($UsernameQuery);

if (trim($ValidEmailDomains)=="")
{
$EmailArray = "";
}
else
{
$EmailArray = split (" ", $ValidEmailDomains);
}

$confirmkey = md5(uniqid(rand()));

// CHECK FOR RESERVED USERNAMES
if (trim($username)=='sa' || trim($username)=='admin' || trim($username)=='test')
{
$UsernameExist = 1;
}

// CHECK FOR REQUIRED FIELDS
if (!trim($username))
{
print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>Username field cannot be left blank!</b></font></p>";
exit;
}
if (!trim($password))
{
print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>Password field cannot be left blank!</b></font></p>";
exit;
}
if (!trim($fname))
{
print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>First Name field cannot be left blank!</b></font></p>";
exit;
}
if (!trim($lname))
{
print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>Last Name field cannot be left blank!</b></font></p>";
exit;
}
if (!trim($email))
{
print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>Email field cannot be left blank!</b></font></p>";
exit;
}

// Validate Email Address String
$good = ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.
'@'.
'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.
'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',
$email);
if (!$good)
{
print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>Email field has invalid characters!</b></font></p>";
exit;
}

// Validate Email Address String - FOR VALID EMAIL DOMAINS
$found=false;
if ($EmailArray!="")
{
for ($ct=0;$ct<=sizeof($EmailArray)-1;$ct++)
{
if (eregi($EmailArray[$ct], $email))
{
$ct=sizeof($EmailArray);
$found=true;
}
else
{
$found=false;
}
}
}
else
{
$found = true;
}
if (!$found)
{
print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>Email address does not belong to the list of allowable email domains!</b></font></p>";
exit;
}

// Make sure username does not yet exist in the db
if ($UsernameExist>0)
{
print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>Username already exists in the database!</b></font></p>";
exit;
}

// Make sure email address does not yet exist in the db
if ($EmailExist>0)
{
print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>Email address already exists in the database!</b></font></p>";
exit;
}

// CHANGE THIS IF YOU WANT TO ADD FIELDS TO YOUR SIGNUP FORM
// Add new member to table signup
$addmember = mysql_query("INSERT INTO signup VALUES ('','$username','$fname','$lname','$email','$country','$zipcode',NOW(),'$confirmkey')");

// If SUCCESSFUL, add to vAuthenticate tables too
if ($addmember)
{
// Is the member auto-approved or not?
if ($AutoApprove==1)
{
$MemberStatus = "active";
}
else
{
$MemberStatus = "inactive";
}

$AddToAuth = new auth();
$add = $AddToAuth->add_user($username,$password,"Ungrouped","999",$MemberStatus,'', 0);
}

// Do we automatically send email notification to member or not?
if ($AutoSend == 1)
{
// if successful in adding to vAuthenticate, send confirmation email
if ($add==1)
{
// Get position of "[[<-" in $EmailMessage and replace it with the HTML anchor tag
$FrtTemplatePos = strpos($EmailerMessage, "[[<-");
$FrtLink = "<a href=\"" . $confirm . "?confirmkey=" . $confirmkey . "\">";

// Get actual length of $EmailMessage
$EmailerMessageLen = strlen($EmailerMessage);

// Replace "[[<-" with HTML anchor
$EmailerMessage = substr_replace($EmailerMessage, $FrtLink, $FrtTemplatePos, 4);

// Get position of "->]]" in $EmailMessage and replace it with the closing HTML anchor tag
$RrTemplatePos = strpos($EmailerMessage, "->]]");
$RrLink = "</a>";

// Replace "->]]" with HTML closing anchor tag
$EmailerMessage = substr_replace($EmailerMessage, $RrLink, $RrTemplatePos, 4);

// Replace occurances of [[--]] in template
$EmailerMessage = str_replace ("[[--]]", $confirm . "?confirmkey=" . $confirmkey, $EmailerMessage);

$sent = @mail($email, $EmailerSubject, $EmailerMessage, "From:$EmailerName<$EmailerFrom>\nReply-to:$EmailerFrom");
}
}

// Do we automatically send notification message to the admin's email address (see signupconfig.php)?
if ($AutoSendAdmin == 1)
{
if ($add==1)
{
$AdminSubject = "New Membership Application!";
$AdminMessage = "This is to inform you that " . $username . " has applied for membership to our site.";
$sent = @mail($adminemail, $AdminSubject, $AdminMessage, "From:$EmailerName<$EmailerFrom>\nReply-to:$EmailerFrom");
}
}
?>

<p><font size="3" face="Verdana, Arial, Helvetica, sans-serif" color="#FF0000"><b>Thank
you for signing up!</b></font></p>

<?
if ($AutoSend == 1)
{
print "<p><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">";
print "A confirmation email was sent to the email address you specified. <br>";
print "Please confirm your membership as soon as you receive the email.";
print "</font></p>";
}
else
{
print "<p><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">";
print "You will now be forwarded to the login area. <br>";
print "If your browser does not automatically load the login area, please click <a href=\"$RelLogin\">here</a>";
print "</font></p>";

?>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("<? echo $RelLogin; ?>");
//-->
</SCRIPT>
<?
}
?>

</body>
</html>