Modern-Empires Posted July 17, 2009 Posted July 17, 2009 Register Page <?php /*-------------------------------------------------------------- - Made by The Phenomenal Ishz - Free CE Members Only - Register Page - Not to be sold. --------------------------------------------------------------*/ session_start(); include "config.php"; global $_CONFIG; define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; $set=array(); $settq=$db->query("SELECT * FROM settings"); while($r=$db->fetch_row($settq)) { $set[$r['conf_name']]=$r['conf_value']; } $q=$db->query("SELECT userid FROM users"); $membs=$db->num_rows($q); $q=$db->query("SELECT * FROM users WHERE laston>unix_timestamp()-15*60 ORDER BY laston DESC"); $online=mysql_num_rows($q); $q=$db->query("SELECT userid FROM users WHERE gender='Male'"); $male=$db->num_rows($q); $q=$db->query("SELECT userid FROM users WHERE gender='Female'"); $fem=$db->num_rows($q); $q=mysql_query("SELECT * FROM users WHERE laston<unix_timestamp()-86400*10 ORDER BY laston DESC",$c); $act=mysql_num_rows($q); $perctact = $membs - $act; $pact = round( ($perctact/$membs)*100, 0 ); while($r=$db->fetch_row($settq)) { $set[$r['conf_name']]=$r['conf_value']; } //thx to [url]http://www.phpit.net/code/valid-email/[/url] for valid_email function valid_email($email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; // Not enough parts to domain } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } session_start(); print <<<EOF <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>{$set['game_name']} Registration</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="imagetoolbar" content="no" /> <meta name="keywords" content="" /> <meta name="description" content="" /> <meta name="author" content="" /> <meta name="copyright" content="" /> <meta name="revisit-after" content="3 days" /> <script type="text/javascript"> var xmlHttp // xmlHttp variable function GetXmlHttpObject(){ // This function we will use to call our xmlhttpobject. var objXMLHttp=null // Sets objXMLHttp to null as default. if (window.XMLHttpRequest){ // If we are using Netscape or any other browser than IE lets use xmlhttp. objXMLHttp=new XMLHttpRequest() // Creates a xmlhttp request. }else if (window.ActiveXObject){ // ElseIf we are using IE lets use Active X. objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP") // Creates a new Active X Object. } // End ElseIf. return objXMLHttp // Returns the xhttp object. } // Close Function function CheckPasswords(password){ // This is our fucntion that will check to see how strong the users password is. xmlHttp=GetXmlHttpObject() // Creates a new Xmlhttp object. if (xmlHttp==null){ // If it cannot create a new Xmlhttp object. alert ("Browser does not support HTTP Request") // Alert Them! return // Returns. } // End If. var url="check.php?password="+escape(password) // Url that we will use to check the password. xmlHttp.open("GET",url,true) // Opens the URL using GET xmlHttp.onreadystatechange = function () { // This is the most important piece of the puzzle, if onreadystatechange = equal to 4 than that means the request is done. if (xmlHttp.readyState == 4) { // If the onreadystatechange is equal to 4 lets show the response text. document.getElementById("passwordresult").innerHTML = xmlHttp.responseText; // Updates the div with the response text from check.php } // End If. }; // Close Function xmlHttp.send(null); // Sends NULL insted of sending data. } // Close Function. function CheckUsername(password){ // This is our fucntion that will check to see how strong the users password is. xmlHttp=GetXmlHttpObject() // Creates a new Xmlhttp object. if (xmlHttp==null){ // If it cannot create a new Xmlhttp object. alert ("Browser does not support HTTP Request") // Alert Them! return // Returns. } // End If. var url="checkun.php?password="+escape(password) // Url that we will use to check the password. xmlHttp.open("GET",url,true) // Opens the URL using GET xmlHttp.onreadystatechange = function () { // This is the most important piece of the puzzle, if onreadystatechange = equal to 4 than that means the request is done. if (xmlHttp.readyState == 4) { // If the onreadystatechange is equal to 4 lets show the response text. document.getElementById("usernameresult").innerHTML = xmlHttp.responseText; // Updates the div with the response text from check.php } // End If. }; // Close Function xmlHttp.send(null); // Sends NULL insted of sending data. } // Close Function. function CheckEmail(password){ // This is our fucntion that will check to see how strong the users password is. xmlHttp=GetXmlHttpObject() // Creates a new Xmlhttp object. if (xmlHttp==null){ // If it cannot create a new Xmlhttp object. alert ("Browser does not support HTTP Request") // Alert Them! return // Returns. } // End If. var url="checkem.php?password="+escape(password) // Url that we will use to check the password. xmlHttp.open("GET",url,true) // Opens the URL using GET xmlHttp.onreadystatechange = function () { // This is the most important piece of the puzzle, if onreadystatechange = equal to 4 than that means the request is done. if (xmlHttp.readyState == 4) { // If the onreadystatechange is equal to 4 lets show the response text. document.getElementById("emailresult").innerHTML = xmlHttp.responseText; // Updates the div with the response text from check.php } // End If. }; // Close Function xmlHttp.send(null); // Sends NULL insted of sending data. } // Close Function. function PasswordMatch() { pwt1=document.getElementById('pw1').value; pwt2=document.getElementById('pw2').value; if(pwt1 == pwt2) { document.getElementById('cpasswordresult').innerHTML="OK"; } else { document.getElementById('cpasswordresult').innerHTML="Not Matching"; } } </script> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body id="home"> <div id="all"> <div id="container"> <div id="header"> <div id="logo"><a href="#">[img=images/logo.gif] <font size=2>[b]The Chaos Revolution[/b]</font></a></div> <div id="head"> <ul> [*][url="#"]<font size=1>Login</font>[/url] [*][url="#"]<font size=1>Register</font>[/url] [*][url="#"]<font size=1>Screenshots</font></font>[/url] [/list] </div> </div> EOF; $IP = ($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; if(file_exists('ipbans/'.$IP)) { die("[b]<font color=red size=+1>Your IP has been banned, there is no way around this.</font>[/b]</body></html>"); } if($_POST['username']) { if($set['regcap_on']) { if(!$_SESSION['captcha'] or $_SESSION['captcha'] != $_POST['captcha']) { unset($_SESSION['captcha']); die("Captcha Test Failed >[url='register.php']Back[/url]"); } unset($_SESSION['captcha']); } if(!valid_email($_POST['email'])) { die("Sorry, the email is invalid. >[url='register.php']Back[/url]"); } if(strlen($_POST['username']) < 4) { die("Sorry, the username is too short. >[url='register.php']Back[/url]"); } $sm=100; if($_POST['promo'] == "Your Promo Code Here") { $sm+=100; } $username=$_POST['username']; $username=str_replace(array("<", ">"), array("<", ">"), $username); $q=$db->query("SELECT * FROM users WHERE username='{$username}' OR login_name='{$username}'"); $q2=$db->query("SELECT * FROM users WHERE email='{$_POST['email']}'"); if($db->num_rows($q)) { print "Username already in use. Choose another. >[url='register.php']Back[/url]"; } else if($db->num_rows($q2)) { print "E-Mail already in use. Choose another. >[url='register.php']Back[/url]"; } else if($_POST['password'] != $_POST['cpassword']) { print "The passwords did not match, go back and try again. >[url='register.php']Back[/url]"; } else if($_POST['squestion'] != $_POST['csquestion']) { print "<h1>ERROR! The Questions Dont Match</h1> >[url='register.php']Back[/url]"; } else { $_POST['ref'] = abs((int) $_POST['ref']); $IP = ($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; $q=$db->query("SELECT * FROM users WHERE lastip='$IP' AND userid={$_POST['ref']}"); if($db->num_rows($q)) { die("No creating referral multies. Bad dog. >[url='register.php']Back[/url]"); } if($_POST['ref']) { $q=$db->query("SELECT * FROM users WHERE userid={$_POST['ref']}"); $r=$db->fetch_row($q); } $db->query("INSERT INTO users (username, login_name, userpass, squestion, level, money, crystals, donatordays, user_level, energy, maxenergy, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip, lastip_signup) VALUES( '{$username}', '{$username}', md5('{$_POST['password']}'), '{$_POST['squestion']}', 1, $sm, 0, 0, 1, 12, 12, 100, 100, 5, 5, 100, 100, 1, '{$_POST['gender']}', unix_timestamp(), '{$_POST['email']}', 0, '$IP', '$IP', random_string('alnum', 32))"); $i=$db->insert_id(); $db->query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10)"); // get data just entered $getUser = mysql_query("SELECT userid, login_name, email, Random_key FROM users WHERE login_name = '{$username}'") or die(mysql_error()); $row = mysql_fetch_assoc($getUser); // Send rego email $stamp = unix_timestamp; $to = $_POST['email']; $subject = "GAME Account Activation"; $body = "Hello " . $username . ",\n\nThank you for registering at Modern-Empires!\n\nClick this link to activate your account: http://www.modern-empires/GAME/activate.php?ID=".$row['userid']."&key=".$row['Random_key']." \n\n -Peter Greenacre"; $headers = "From: [email][email protected][/email]\r\n"; if (mail($to, $subject, $body, $headers)) {} if($_POST['ref']) { require "global_func.php"; $db->query("UPDATE users SET crystals=crystals+2 WHERE userid={$_POST['ref']}"); event_add($_POST['ref'],"For referring $username to the game, you have earned 2 valuable crystalliums!",$c); $db->query("INSERT INTO referals VALUES('', {$_POST['ref']}, $i, unix_timestamp(),'{$r['lastip']}','$IP')"); } print "You have signed up, enjoy the game. > [url='login.php']Login[/url]"; } } else { if($set['regcap_on']) { $chars="123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!?\\/%^"; $len=strlen($chars); $_SESSION['captcha']=""; for($i=0;$i<6;$i++) $_SESSION['captcha'].=$chars[rand(0, $len - 1)]; } $year=date('Y'); echo ' <div id="main"> <div id="menu"> <h2>Member Login</h2><center> <form action="authenticate.php" method="post" name="login" onsubmit="return saveme();" > Username: <input type="text" name="username" /> Password: <input type="password" name="password" /> Remember me? <input type="radio" value="ON" name="save" />Yes <input type="radio" name="save" value="OFF" />No <input type="submit" value="Submit" /></form> [url="#"]<font size=1>Forgot your password?[/url] [url="#"]Not registered?</font>[/url] </p></center> <h2>Game Stats</h2> <center> Registered Users: '.$membs.' Total Online: '.$online.' Total Males: '.$male.' Total Females: '.$fem.' Percent Active: '.$pact.' </center> </div> <div id="text"> <h2>Registration</h2> <form action="register.php" method="post" /> <table width="75%" border="0" class="table" cellspacing="1"> <tr> <td width="30%">Username</td> <td width="40%"><input type="text" name="username" onkeyup="CheckUsername(this.value);" /></td> <td width="30%"><div id="usernameresult"></div></td> </tr> <tr> <td>Password</td> <td><input type="password" id="pw1" name="password" onkeyup="CheckPasswords(this.value);PasswordMatch();" /></td> <td><div id="passwordresult"></div></td> </tr> <tr> <td>Confirm Password</td><td><input type="password" name="cpassword" id="pw2" onkeyup="PasswordMatch();" /></td> <td><div id="cpasswordresult"></div></td> </tr> <tr> <td>Secret Question</td> <td><input type="text" name="squestion" /></td> </tr> <tr> <td>Re-type Secret Question</div></td> <td><input type="text" name="csquestion" /> </td> </tr> <tr> <td>Email</td><td><input type="text" name="email" onkeyup="CheckEmail(this.value);" /></td> <td><div id="emailresult"></div></td> </tr> <tr> <td>Gender</td> <td colspan="2"> <select name="gender"> <option value="Male">Male</option> <option value="Female">Female</option> </select></td> </tr> <tr> <td>Promo Code</td><td colspan="2"><input type="text" name="promo" /></td> </tr>'; print" <tr><td>Captcha</td><td colspan='2'><input type='hidden' name='ref' value='"; if($_GET['REF']) { print $_GET['REF']; } print "' />"; if($set['regcap_on']) { print " [img=captcha_verify.php?bgcolor=C3C3C3] <input type='text' name='captcha' /></td> </tr>"; } print " <tr> <td colspan='3'><center><input type='submit' value='Submit' /></center></td> </tr> </table></center> [url=''][/url]"; } echo' </div> </div> <div id="footer"> <center><div id="left_footer">© Copyright 2009</div></center> <div id="right_footer"> [url="TOS.php"]Terms of Service[/url] | [url="contact.php"]Contact Us[/url] </div> </div> </div> </div> <div id="bottom"> <div id="bottom_center"></div> </div> </div> </body> </html>'; ?> Database CREATE TABLE IF NOT EXISTS `users` ( `userid` int(11) NOT NULL auto_increment, `username` varchar(255) NOT NULL default '', `userpass` varchar(255) NOT NULL default '', `level` int(11) NOT NULL default '0', `exp` decimal(11,4) NOT NULL default '0.0000', `money` int(11) NOT NULL default '0', `crystals` int(11) NOT NULL default '0', `laston` int(11) NOT NULL default '0', `lastip` varchar(255) NOT NULL default '', `job` int(11) NOT NULL default '0', `energy` int(11) NOT NULL default '0', `will` int(11) NOT NULL default '0', `maxwill` int(11) NOT NULL default '0', `brave` int(11) NOT NULL default '0', `maxbrave` int(11) NOT NULL default '0', `maxenergy` int(11) NOT NULL default '0', `hp` int(11) NOT NULL default '0', `maxhp` int(11) NOT NULL default '0', `lastrest_life` int(11) NOT NULL default '0', `lastrest_other` int(11) NOT NULL default '0', `location` int(11) NOT NULL default '0', `hospital` int(11) NOT NULL default '0', `jail` int(11) NOT NULL default '0', `jail_reason` varchar(255) NOT NULL default '', `fedjail` int(11) NOT NULL default '0', `user_level` int(11) NOT NULL default '1', `gender` enum('Male','Female') NOT NULL default 'Male', `daysold` int(11) NOT NULL default '0', `signedup` int(11) NOT NULL default '0', `gang` int(11) NOT NULL default '0', `daysingang` int(11) NOT NULL default '0', `course` int(11) NOT NULL default '0', `cdays` int(11) NOT NULL default '0', `jobrank` int(11) NOT NULL default '0', `donatordays` int(11) NOT NULL default '0', `email` varchar(255) NOT NULL default '', `login_name` varchar(255) NOT NULL default '', `display_pic` text NOT NULL, `duties` varchar(255) NOT NULL default 'N/A', `bankmoney` int(11) NOT NULL default '0', `cybermoney` int(11) NOT NULL default '-1', `staffnotes` longtext NOT NULL, `mailban` int(11) NOT NULL default '0', `mb_reason` varchar(255) NOT NULL default '', `hospreason` varchar(255) NOT NULL default '', `lastip_login` varchar(255) NOT NULL default '127.0.0.1', `lastip_signup` varchar(255) NOT NULL default '127.0.0.1', `last_login` int(11) NOT NULL default '0', `voted` text NOT NULL, `crimexp` int(11) NOT NULL default '0', `attacking` int(11) NOT NULL default '0', `verified` int(11) NOT NULL default '0', `forumban` int(11) NOT NULL default '0', `fb_reason` varchar(255) NOT NULL default '', `posts` int(11) NOT NULL default '0', `forums_avatar` varchar(255) NOT NULL default '', `forums_signature` text NOT NULL, `new_events` int(11) NOT NULL default '0', `new_mail` int(11) NOT NULL default '0', `friend_count` int(11) NOT NULL default '0', `enemy_count` int(11) NOT NULL default '0', `new_announcements` int(11) NOT NULL default '0', `boxes_opened` int(11) NOT NULL default '0', `user_notepad` text NOT NULL, `equip_primary` int(11) NOT NULL default '0', `equip_secondary` int(11) NOT NULL default '0', `equip_armor` int(11) NOT NULL default '0', `force_logout` tinyint(4) NOT NULL default '0', `fishing_aloud` int(11) NOT NULL default '20', `squestion` varchar(255) NOT NULL, `Random_key` varchar(32) default NULL, `activated` int(1) NOT NULL default '0', PRIMARY KEY (`userid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ; i cant work out where the error is between these 2, the error is QUERY ERROR: Column count doesn't match value count at row 1 Query was INSERT INTO users (username, login_name, userpass, squestion, level, money, crystals, donatordays, user_level, energy, maxenergy, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip, lastip_signup) VALUES( 'Test', 'Test', md5('123456789'), 'secretanswer', 1, 100, 0, 0, 1, 12, 12, 100, 100, 5, 5, 100, 100, 1, 'Male', unix_timestamp(), '[email protected]', 0, '88.107.133.23', '88.107.133.23', random_string('alnum', 32)) Quote
Faz` Posted July 17, 2009 Posted July 17, 2009 Re: Register.php problem with V2 Read again what the error is saying, its self-explanatory, instead of posting every time you get stuck, take time to actually try and figure it out yourself. It'll help you learn much quicker. Quote
Modern-Empires Posted July 17, 2009 Author Posted July 17, 2009 Re: Register.php problem with V2 i have looked at this error and this is one of my first time i've asked help for like this, i've been trying to work this out for hours now Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.