Give people an adoptable/cash on ther birthday!

Forum
Last Post
Threads / Messages

PokePets

Premium Member
Premium Member
Joined
Jun 29, 2010
Messages
227
Points
0
Mysidian Dollar
13,596
With this script, users will get an adoptable or cash on ther birthday. Nice gift, not?
Specials thanks to fadillzzz who helped me fixing errors etc.

1) Search in account.php for this;

//Loop out code
$i=0;
while ($i < 1) {

$newmessagenotify=@mysql_result($result,$i,"newmessagenotify");
$website=@mysql_result($result,$i,"website");
$aim=@mysql_result($result,$i,"aim");
$yahoo=@mysql_result($result,$i,"yahoo");
$msn=@mysql_result($result,$i,"msn");

Under that part of the code, add this;
$birthday=@mysql_result($result,$i,"birthday");

2) We are not done with account.php !
Look for this code;

</p>
<p>MSN Username:
<input name='msn' type='text' id='msn' value='".$msn."'>
<input name='act' type='hidden' id='act' value='changesettings'>
</p>

Under that, add this;
<p>Birthday:
<input name='birthday' type='text' id='birthday' value='".$birthday."'>

!! The birthday must be entered so;
Example for 31 Jan. 31 01
So 2 figures for the day, then a space end then 2 figures for the month.

3) Now we are done with account.php
Open now accountpost.php end look for this part of the code;

$aim = $_POST["aim"];
$aim = secure($aim);

$yim = $_POST["yim"];
$yim = secure($yim);

$msn = $_POST["msn"];
$msn = secure($msn);

Under that, add this;

$birthday= $_POST["birthday"];
$birthday= secure($birthday);

4) We must edit another thing in accountpost.php !
Look for this code;

$query = "UPDATE ".$prefix."users SET msn='".$msn."' WHERE username='".$loggedinname."'";
mysql_query($query);

End ad this;

$query = "UPDATE ".$prefix."users SET birthday='".$birthday."' WHERE username='".$loggedinname."'";
mysql_query($query);

5) Accountpost.php is ready. Now you need to creat 2 new colum in _users ;

Name: alreadybirthday
Type: Varchar 10
Collation: latin1_swedish_ci
Null: No
Default Value: Not

&

Name: birthday
Type: Varchar 10
Collation: latin1_swedish_ci
Null: No

6) We edited our _users table, so we must update our register.php !
Search for ;

//All checks are done, actually create the user's account on the database

$date = date('Y-m-d');

mysql_query("INSERT INTO ".$prefix."users VALUES ('', '$username', '$pass1','$email','3','1', '$date', '0','','','','','')");

& change it to

//All checks are done, actually create the user's account on the database

$date = date('Y-m-d');

mysql_query("INSERT INTO ".$prefix."users VALUES ('', '$username', '$pass1','$email','3','1', '$date', '0','','','','','','','')");
7) Now users can set ther birthday.
Now you can use this file to give your users a special adoptable on ther birthday;

<?php


// ************************************************** ********************
// Basic Configuration Info
// ************************************************** ********************

include("inc/functions.php");
include("inc/config.php");

$themeurl = grabanysetting("themeurl");

// ************************************************** ********************
// Define our top links by calling getlinks()
// ************************************************** ********************

$links = getlinks();

// ************************************************** ********************
// Define our ads by calling getads()
// ************************************************** ********************

$ads = getads("any");

// ************************************************** ********************
// Grab any settings that we will need for the current page from the DB
// ************************************************** ********************

$browsertitle = grabanysetting("browsertitle");
$sitename = grabanysetting("sitename");
$slogan = grabanysetting("slogan");

// ************************************************** ********************
// Check and see if the user is logged in to the site
// ************************************************** ********************

$loginstatus = logincheck();
$isloggedin = $loginstatus[loginstatus];
$loggedinname = $loginstatus[username];

// ************************************************** ********************
// End Prepwork - Output the page to the user
// ************************************************** ********************

$query = "SELECT * FROM ".$prefix."users WHERE username='$loggedinname'";
$result = mysql_query($query);
$num = mysql_num_rows($result);

//Loop out code
$i=0;
while ($i < 1) {

$birthday=@mysql_result($result,$i,"birthday") ;
$alreadybirthday=@mysql_result($result,$i,"alreadybirthday") ;
$date = date("d m");
$code = rand(1, 20000);

$i++;
}

if($birthday == $date){

if ($alreadybirthday != "yes"){

$article_title = "Happy Birthday!";
$article_content = "As gift you get a special adoptable!";

mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', 'TYPEOFSPECIALADOPTABLE', 'Happy B-day!','$loggedinname','1','2', '$code', '','no','notfortrade','no')" );

$query = "UPDATE ".$prefix."users SET alreadybirthday='yes' WHERE username='".$loggedinname."'";
mysql_query($query);
}

elseif ($alreadybirthday == "yes"){
$article_title = "Is it your birthday?";
$article_content = "Yes, but you got already a gift!
It's today: ".$date." ! ";
}

}

else{

$article_title = "Is it your birthday";
$article_content = "No :(!
! It's today ".$date." !";

}



// ************************************************** ********************
// Begin Template Definition
// ************************************************** ********************

//Define our current theme
$file = $themeurl;

// Do the template changes and echo the ready template
$template = file_get_contents($file);
//echo $file;

$template = replace(':ARTICLETITLE:',$article_title,$template) ;
$template = replace(':ARTICLECONTENT:',$article_content,$template);
$template = replace(':ARTICLEDATE:',$article_date,$template);

$template = replace(':BROWSERTITLE:',$browsertitle,$template);
$template = replace(':SITENAME:',$sitename,$template);

//Define our links
$template = replace(':LINKSBAR:',$links,$template);

//Get the content for the side bar...
$sidebar = getsidebar();
$template = replace(':SIDEFEED:',$sidebar,$template);

echo $template;

// ************************************************** ********************
// End Template Definition
// ************************************************** ********************
?>

You can do this also with cash etc. , will come soon!
 
Last edited:
You forgot to tell everyone to update the INSERT query in the register.php to insert 2 more values for the new columns that were created.
 
Well yeah, this is usually the cause of bugs regarding changes of table prefix_users. I pointed it out to Anna on her avatar mod before, but seems that she still made the same mistake when doing her whos online script. I will post a thread to remind every aspiring coders about something like this when Mys v1.2.0 is released.
 
lol, I'm a slow learner, I guess?

I usually do mention always check the code because I have LOTS of special and different stuff in there, but ....yeah, always forget that part!
 
Last edited:

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top