havemybabies Posted November 21, 2011 Share Posted November 21, 2011 For some reason, and I cant freakin' figure out why- when I register it doesn't show up under "login" table in sql DB! Matter of fact; it doesn't show up anywhere at all. It gives me the "Thank you for joining. Your account has been activated." message, but it's all liez! ;p connect.php <?php session_start(); $connect = mysql_connect("localhost", "root", "123"); if($connect == TRUE) { if(mysql_select_db("smugglersworld") != TRUE) { exit("<span style='color: red'>Can't connect to the MySQL database. Please contact the webmaster.</body></html>"); } }else{ exit("<span style='color: red'>Can't connect to the MySQL server. Please contact the webmaster.</body></html>"); } ?> register.php <?php include_once("safe/config.php"); include_once("safe/connect.php"); ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Register.</title> <link href="theme/style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- body { background-color: #222222; } --> </style> </head> <body> <table width="800" border="0" align="center" cellspacing="0"> <tr> <td><table border="0" align="center" cellspacing="2"> <tr> <td class="off" onmouseover="this.className='on'" onmouseout="this.className='off'" onclick="location.href='index.php'"><a href="index.php" onFocus="if(this.blur)this.blur()">Login.</a></td> <td class="off" onmouseover="this.className='on'" onmouseout="this.className='off'" onclick="location.href='register.php'"><a href="register.php" onFocus="if(this.blur)this.blur()">Register.</a></td> <td class="off" onmouseover="this.className='on'" onmouseout="this.className='off'" onclick="location.href='forgot.php'"><a href="forgot.php" onFocus="if(this.blur)this.blur()">Forgot Password.</a></td> <td class="off" onmouseover="this.className='on'" onmouseout="this.className='off'" onclick="location.href='screenshots.php'"><a href="screenshots.php" onFocus="if(this.blur)this.blur()">Screenshots.</a></td> </tr> </table></td> </tr> <tr> <td height="250" align="center" valign="middle"><img src="img/index.jpg" alt="Gangster legends" /> </td> </tr> <tr> <td align="center" valign="top"><form id="register" name="register" method="post" action=""> <table width="400" border="0" align="center" cellspacing="0"> <tr> <td height="20" colspan="2" align="center" valign="middle"><?php if(isset($_POST['Register'])){ $sql = "SELECT status FROM sitestats WHERE id='1'"; $query = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_object($query); $page_status = htmlspecialchars($row->status); $page_status_array = explode("-", $page_status); if(!empty($page_status_array[32])){ echo htmlspecialchars(stripslashes($page_status_array[32])); }else{ if ((strlen($_POST['password']) > "20") or (strlen($_POST['password']) < "6")){ echo "Your Password needs to be between 6 and 20 characters long."; }else{ if ((strlen($_POST['name']) > "20") or (strlen($_POST['name']) < "2")){ echo "Your name needs to be between 2 and 20 characters long."; }else{ if($_POST['mail'] != $_POST['mail_check']){ echo "The 2 given email's didn't match."; }else{ if($_POST['password'] != $_POST['password_check']){ echo "The 2 given Passwords's didn't match."; }else{ if(empty($_POST['tos'])){ echo "You need to accept the Terms of Service in order to play Gangster Basics."; }else{ $sql = "SELECT id FROM login WHERE name='".mysql_real_escape_string($_POST['name'])."'"; $query = mysql_query($sql) or die(mysql_error()); $count = mysql_num_rows($query); if($count >= "1"){ echo "This username is already taken."; }else{ $sql = "SELECT id FROM login WHERE mail='".mysql_real_escape_string($_POST['mail'])."'"; $query = mysql_query($sql) or die(mysql_error()); $m_count = mysql_num_rows($query); if($m_count >= "1"){ echo "This email has already been used."; }else{ if(!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$/i", $_POST['mail'])) { echo "Please use a valid email address."; }else{ if (preg_match('/[^A-Za-z0-9]/', $_POST['name'])) { echo "Invalid Name only A-Z,a-z and 0-9 is allowed."; }else{ if (preg_match('/[^A-Za-z0-9]/', $_POST['ref'])) { echo "Invalid Name only A-Z,a-z and 0-9 is allowed."; }else{ $sql = "SELECT id FROM login WHERE name='".mysql_real_escape_string($_POST['ref'])."'"; $query = mysql_query($sql) or die(mysql_error()); $a_count = mysql_num_rows($query); if(empty($a_count) and !empty($_POST['ref'])){ echo "Your referral does not play this game."; }else{ if(($_POST['location'] > "9") or ( $_POST['location'] < "1")){ echo "Invalid Location."; }else{ $pass = md5($_POST['password']); $sql = "INSERT INTO login SET id = '', name = '" .mysql_real_escape_string($_POST['name']). "', signup =NOW() , password = '" .mysql_real_escape_string($pass). "', state = '0', mail = '" .mysql_real_escape_string($_POST['mail']). "',location='".mysql_real_escape_string($_POST['location'])."', signup_ip='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."',ref='".mysql_real_escape_string($_POST['ref'])."'"; $res = mysql_query($sql); // send email. // echo "Thank you for joining. Your account has been activated."; }}// referrals check. }// check if email is used. }// check if the 2 passwords match. }// check if valid location. }// check name characters. }// check if valid email. }// check if name is unused. }// check if accepted to the tos. }// check if 2 mails are the same. }// name check. }// password check. }// if disabled. }// if post register. ?></td> </tr> <tr> <td colspan="2" align="left"><strong>Account Information: </strong></td> </tr> <tr> <td width="130" align="left"><label>Username:</label></td> <td align="center"><input name="name" type="text" class="entryfield" id="name" style='width: 98%;' maxlength="20" /></td> </tr> <tr> <td width="130" align="left"><label>Email:</label></td> <td align="center"><input name="mail" type="text" class="entryfield" id="mail" style='width: 98%;' /></td> </tr> <tr> <td width="130" align="left">Repeat:</td> <td align="center"><input name="mail_check" type="text" class="entryfield" id="mail_check" style='width: 98%;' /></td> </tr> <tr> <td width="130" align="left"><label>Password:</label></td> <td align="center"><input name="password" type="password" class="entryfield" id="password" style='width: 98%;' maxlength="20" /></td> </tr> <tr> <td width="130" align="left">Repeat:</td> <td align="center"><input name="password_check" type="password" class="entryfield" id="password_check" style='width: 98%;' maxlength="20" /></td> </tr> <tr> <td align="left">Referral:</td> <td align="center"><input name="ref" type="text" class="entryfield" id="ref" style='width: 98%;' value="<?php echo $_GET['ref']; ?>" maxlength="20" /></td> </tr> <tr> <td width="130" align="left"> Location:</td> <td align="center"><select name="location" class="entryfield" id="location"> <option value="1">London.</option> <option value="2">Rome.</option> <option value="3">Tokyo.</option> <option value="4">Paris.</option> <option value="5">Chicago.</option> <option value="6">Sydney.</option> <option value="7">Madrid.</option> <option value="8">Hong Kong.</option> <option value="9">Moscow.</option></select> </td> </tr> <tr> <td colspan="2" align="left"> </td> </tr> <tr> <td width="130" align="left"><a onClick="tos()"> <label>Terms of Service:</label> </a></td> <td align="left"><input name="tos" type="checkbox" id="terms" value="true" onFocus="if(this.blur)this.blur()"/> <label for="terms">I have read and agree to the Terms of Service.</label></td> </tr> <tr> <td colspan="2" align="right"><input name="Register" type="submit" class="button" id="Register" value="Register." onfocus="if(this.blur)this.blur()"/> </td> </tr> <tr> <td colspan="2" align="center"><a href="tos.php" target="_blank" onfocus="if(this.blur)this.blur()">Terms of Service.</a></td> </tr> <tr> <td colspan="2" align="right"> </td> </tr> </table> </form></td> </tr> </table> <center> © www.glscript.net </center> </body> </html> All I really did was to remove the send email stuff since I dont really need it and change ereg to preg_match, but it didn't work long before I changed these things. It. Has. Never. Worked. Any help on the matter would be greatly appriciated! Cheers. Quote Link to comment Share on other sites More sharing options...
Ninja Posted November 21, 2011 Share Posted November 21, 2011 are you sure you used the right info to the right db Quote Link to comment Share on other sites More sharing options...
havemybabies Posted November 21, 2011 Author Share Posted November 21, 2011 are you sure you used the right info to the right db if(mysql_select_db("smugglersworld") != TRUE) { smugglersworld is the right DB. It's the only DB. So.. I guess so? ;p Quote Link to comment Share on other sites More sharing options...
Ninja Posted November 21, 2011 Share Posted November 21, 2011 what about this? lol $connect = mysql_connect("localhost", "root", "123"); did you edit that for the post or is that how the code is? Maybe you should change them that is what i would try. And what engine are you useing? i do not have a connect.php Quote Link to comment Share on other sites More sharing options...
havemybabies Posted November 21, 2011 Author Share Posted November 21, 2011 what about this? lol $connect = mysql_connect("localhost", "root", "123"); did you edit that for the post or is that how the code is? Maybe you should change them that is what i would try. And what engine are you useing? i do not have a connect.php It connects to localhost and the DB just fine. I'm using Gangster Legends. Quote Link to comment Share on other sites More sharing options...
Equinox Posted November 21, 2011 Share Posted November 21, 2011 $sql = "INSERT INTO login SET id = '', name = '" .mysql_real_escape_string($_POST['name']). "', signup =NOW() , password = '" .mysql_real_escape_string($pass). "', state = '0', mail = '" .mysql_real_escape_string($_POST['mail']). "',location='".mysql_real_escape_string($_POST['location'])."', signup_ip='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."',ref='".mysql_real_escape_string($_POST['ref'])."'"; $res = mysql_query($sql); All wrong.... $sql = "INSERT INTO login (id,name,signup,password,state,mail,location,signup_ip,ref) VALUES('', '" .mysql_real_escape_string($_POST['name']). "',NOW() , '" .mysql_real_escape_string($pass). "', 0, '" .mysql_real_escape_string($_POST['mail']). "','".mysql_real_escape_string($_POST['location'])."','".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."','".mysql_real_escape_string($_POST['ref'])."')"; $res = mysql_query($sql) or die(mysql_error()); Another problem could be the quotes - but I cannot see them properly, so cannot judge. But try that. Quote Link to comment Share on other sites More sharing options...
modernmafia Posted November 21, 2011 Share Posted November 21, 2011 ill help you fix it Quote Link to comment Share on other sites More sharing options...
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.