adding +1 per email???
Moderator: General Moderators
adding +1 per email???
Hey everyone. I'm working on a website and i'm trying to do something, but don't know if it can be done. I want my users to accumulate points based on referring new users. I've set up the register.php page to record the usual name, password, email address and have added a "reference" option for users to enter an email address of the user that referred them. everything records to the user database correctly. now here's to my question.
I've added another "numeric" column called "reference_points". Is there any code i could use that when a new user is registering, the "reference" column does a search against the "email" column and adds 1 point to the "reference_points" column for the user who's "email" matched the "reference" that the new user entered, and also gave an error message(which isn't nearly as important) if the email address put as a reference didn't exist?
Is this making any since? I've been using php for a long time, but never custom code, always altering templates to fit my needs. So i've learned just enough to be dangerous, as they say.
if it helps at all, here's the link to the register page:
http://www.gamerz-haven.net/register.php
also adding this to Database, it's kind of both...
I've added another "numeric" column called "reference_points". Is there any code i could use that when a new user is registering, the "reference" column does a search against the "email" column and adds 1 point to the "reference_points" column for the user who's "email" matched the "reference" that the new user entered, and also gave an error message(which isn't nearly as important) if the email address put as a reference didn't exist?
Is this making any since? I've been using php for a long time, but never custom code, always altering templates to fit my needs. So i've learned just enough to be dangerous, as they say.
if it helps at all, here's the link to the register page:
http://www.gamerz-haven.net/register.php
also adding this to Database, it's kind of both...
Re: adding +1 per email???
Uh...
Code: Select all
UPDATE table SET reference_points = reference_points + 1 WHERE email = "..."Code: Select all
if (mysql_affected_rows() == 1) {
// okay
} else {
// no such email
}Re: adding +1 per email???
ok i feel like an idiot, but i can't make it work. i tried just how you had it, and am getting a parse error, so i tried it differently and the error is the same
Code: Select all
<?php
$conn = @mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) or die(mysql_error());
mysql_select_db(MYSQL_BASE_LS, $conn) or die(mysql_error());
$sql = "SELECT reference,
reference_points,
email,
FROM ".MYSQL_BASE_LS.".account_data,";
$sql = UPDATE TABLE SET "reference_points" = "reference_points" + 1 WHERE email = LG_REFERENCE;
if (mysql_affected_rows() == 1) {
// okay
} else {
// no such email
}
?>Re: adding +1 per email???
Looks like you need a tutorial.
Re: adding +1 per email???
ok the tutorial worked well to get rid of the errors, but it still doesn't work....
i feel like a real moron here...
Code: Select all
<tr>
<td height="30" align="right"><strong><?php echo LG_REFERENCE;?>:</strong></td>
<td height="30"> <input name="reference" id="reference" type="text" class="inputs" style="width:100px;" maxlength="65" />
</td>
</tr>
</form>
</table>
<?php
@mysql_select_db(MYSQL_BASE_LS) or die( "Unable to select database");
mysql_query($query);
$ud_ref=$_POST['reference'];
$query = "UPDATE account_data SET $ud_ref = 'reference_points' + 1 WHERE email = reference";
if (mysql_affected_rows() == 1) {
// okay
} else {
// no such email
}
?>Re: adding +1 per email???
ok im getting closer...
my problem is "WHERE email = blah blah blah
i can't figure out how to make it equal whatever it is that users put in that input box.
the box is...
Code: Select all
<?php
@mysql_select_db(MYSQL_BASE_LS) or die( "Unable to select database");
mysql_query($query);
$query = "UPDATE account_data SET reference_points = reference_points + 1 WHERE email = reference";
if (mysql_affected_rows() == 1) {
// okay
} else {
// no such email
}
?>i can't figure out how to make it equal whatever it is that users put in that input box.
the box is...
Code: Select all
<tr>
<td height="30" align="right"><strong><?php echo LG_REFERENCE;?>:</strong></td>
<td height="30"> <input name="reference" id="reference" type="text" class="inputs" style="width:100px;" maxlength="65" />
</td>
</tr>Re: adding +1 per email???
Code: Select all
if (isset($_POST['reference'])) {
@mysql_select_db(MYSQL_BASE_LS) or die( "Unable to select database");
$reference=$_POST['reference'];
$query = "UPDATE account_data SET reference_points=reference_points+1
WHERE email='" . mysql_real_escape_string($reference) . "'";
$result=mysql_query($query);
if (mysql_affected_rows() == 1) {
// okay
} else {
// no such email
}
}