JonasPHPgutt Posted January 10, 2010 Share Posted January 10, 2010 Hello, I am currently creating an online text based game and I am wondering, what is wrong with this code: <title>MafiaNor</title> <?php /* ------------------------- */ $banner = "no"; include("login.php"); if(isset($_POST['login'],$_POST['pass'])) { $_POST['login'] = quote_smart($_POST['login']); $_POST['pass'] = quote_smart($_POST['pass']); $dbres = mysql_query("SELECT `login`,`activated` FROM `[users]` WHERE `login`='{$_POST['login']}' AND `pass`='{$_POST['pass']}'"); if(($data = mysql_fetch_object($dbres)) && $data->activated == 1) { $validate = rand(0,1000); setcookie("login",$data->login,time()+60*60*24,"/","http://mafianor.org/"); setcookie("validate",$validate,time()+60*60*24,"/","http://mafianor.org/"); mysql_query("REPLACE INTO `[online]`(`time`,`login`,`IP`,`validate`) values(NOW(),'{$_SERVER['REMOTE_ADDR']}','{$data->login}','$validate')"); $_SESSION['login'] = $data->login; $_SESSION['IP'] = $_SERVER['REMOTE_ADDR']; $dbres = mysql_query("SELECT *,UNIX_TIMESTAMP(`signup`) AS `signup` FROM `[users]` WHERE `login`='{$_SESSION['login']}'"); $_SESSION['data'] = mysql_fetch_object($dbres); } } else if($_GET['x'] == "logout") { mysql_query("DELETE FROM `[online]` WHERE `login`='{$_COOKIE['login']}' AND `validate`='{$_COOKIE['validate']}' AND `IP`='{$_SERVER['REMOTE_ADDR']}'"); setcookie("login",'',time()-24*60*60,"/",""); setcookie("validate",'',time()-24*60*60,"/",""); unset($_SESSION['login']); unset($_SESSION['IP']); unset($_SESSION['data']); } /* ------------------------- */ ?> <body> <link rel="stylesheet" type="text/css" href="css-v1.css"> <?php /* ------------------------- */ if($_GET['x'] == "logout") echo " <script language=\"javascript\">top.location.replace('index.php');</script>"; else if($_GET['x'] == "lostpass") { print " <table align=\"center\" width=100%><tr><td class=\"subTitle\"><b>Glemt passord?</b></td></tr>\n"; if(isset($_GET['id'],$_GET['code'])) { $_GET['id'] = quote_smart($_GET['id']); $_GET['code'] = quote_smart($_GET['code']); $dbres = mysql_query("SELECT `login` FROM `[temp]` WHERE `id`='{$_GET['id']}' AND `code`='{$_GET['code']}' AND `area`='lostpass'"); if($data = mysql_fetch_object($dbres)) { $dbres = mysql_query("SELECT `login`,`email` FROM `[users]` WHERE `login`='{$data->login}'"); $data = mysql_fetch_object($dbres); include_once("RPG/rndPass.class.php"); $pass=new rndPass(7); $pass=$pass->PassGen(); mysql_query("UPDATE `[users]` SET `pass`='$pass' WHERE `login`='$data->login'"); mysql_query("DELETE FROM `[temp]` WHERE `id`='{$_GET['id']}'"); mail($data->email,"MafiaNor passord","Ditt passord har blitt nullstilt.\n Her er ditt nye passord: {$pass}.\n Vær vennlig å behold det på en trygg plass.\n\Vennlig hilsen,\nMafiaNor Ledelsen\nhttp://mafianor.org/ ","Fra: MafiaNor \n"); print " <tr><td class=\"mainTxt\">Ditt passord har blitt sendt til eposten din.!</td></tr>\n"; } echo '</table>'; } else if(isset($_POST['email'],$_POST['login'])) { $_POST['email'] = quote_smart($_POST['email']); $_POST['login'] = quote_smart($_POST['login']); $dbres = mysql_query("SELECT `login`,`email` FROM `[users]` WHERE `login`='{$_POST['login']}' AND `email`='{$_POST['email']}'AND `activated`=1"); if($data = mysql_fetch_object($dbres)) { $code = rand(10000,99999); mysql_query("INSERT INTO `[temp]`(`login`,`code`,`area`,`time`) values('{$data->login}',$code,'lostpass',NOW())"); $id = mysql_insert_id(); mail($data->email,"MafiaNor Passord","Hei!","Vi ser at du ønsker å endre ditt passordet på brukeren din hos MafiaNor. \nHvis det ikke var deg som ba om å få tilsendt nytt passord, så trenger du bare å ignorere denne mailen. \nHvis det var deg, klikk på denne linken:\nhttp://mafianor.org/login.php?x=lostpass&id=$id&code=$code\n \nVennlig hilsen,\nMafiaNor Ledelsen\n http://mafianor.org ","Fra: MafiaNor"); print " <table align=\"center\" width=100%> <tr><td class=\"mainTxt\">Mailen har blitt sendt til {$data->email}, Sjekk eposten din! Sjekk søppelpost hvis den ikke kommer.</td></tr></table>\n"; } else print " <table align=\"center\" width=100%> <tr><td class=\"mainTxt\">Fant ikke epost adressen din.</td></tr></table>\n"; } print <<<ENDHTML <table align="center" width=100%><tr><td class="mainTxt" align="center"><br> <form method="post"><table> <tr><td>Brukernavn:</td> <td><input type="text" name="login"></td></tr> <tr><td>E-post:</td> <td><input type="text" name="email"></td></tr> <tr><td></td> <td align="right"><input type="submit" value="Ok" style="width: 100"></td></tr> </form></table></td></tr></table> ENDHTML; } else if($data) { if($data->activated == 0) print " <table align=\"center\" width=100%><tr><td class=\"mainTxt\"><font color=red><b>Du har ikke aktivert brukeren din! Aktiver den og prøv igjen! Hvis du ikke har fått mail, så ligger den kanskje på søppelpost</b></font></td></tr></table>\n"; else header("Location: index.php"); } else { // login form echo ' <style type="text/css"> <!-- body { margin-right: 100px; } a:link { color: #FFFFFF; } a:visited { color: #FFFFFF; } a:hover { color: #00CCFF; } a:active { color: #FFFFFF; } --> html { height: 100%; margin: 0; padding: 0; } body { height: 100%; margin: 0; padding: 0; } #login { width: 800px; height: 600px; border: 2px solid #000; position: relative; overflow: hidden; } #login_input { position: absolute; text-align: center; left: 16px; bottom: 200px; } #login_user, #login_pass { width: 110px } #login_submit { width: 80px } #login_ekstra { position: absolute; bottom: 170px; left: 360px; width: 220px; text-align: center; } </style> <table width="100%" height="100%"> <tr> <td align="center" valign="middle"> <div id="login">'; if (isset($_POST['login'], $_POST['pass'])) { echo ' <div id="login_error">Feil brukernavn eller passord. </div>'; } echo ' <center><img src="http://i35.tinypic.com/ng1wzk.gif" alt="MafiaNor!" width="800" height="600" title="MafiaNor!"> </center> <div id="login_input"> <form method="post"> <table width="570" align="right"> <tr> <td><div align="right">Brukernavn:</div></td> <td><input type="text" onfocus="if(this.value==\'Brukernavn\')this.value=\'\'" onblur=" if(this.value==\'\')this.value=\'Brukernavn\'" name="login" maxlength="16" id="login_user" value="Brukernavn"></td> </tr> <tr> <td><div align="right">Passord:</div></td> <td><input type="password" onfocus="if(this.value==\'Passord\')this.value=\'\'" onblur=" if(this.value==\'\')this.value=\'Passord\'"name="pass" maxlength="16" id="login_pass" value="Passord"></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" id="login_submit" value="Logg inn!"></td> </tr> </table> </form> </div> <div id="login_ekstra"> <div align="right"><a href="signup.php?x=Signup">Registrer deg!</a> | <a href="login.php?x=lostpass">Glemt Passord?</a> </div> </div> </div> </td> </tr> </table>'; } ?> </table> </body> </html> Thanks for your time Quote Link to comment https://forums.phpfreaks.com/topic/187975-help-coding-please-look/ Share on other sites More sharing options...
teamatomic Posted January 10, 2010 Share Posted January 10, 2010 If you are getting an error we would like to see it. HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/187975-help-coding-please-look/#findComment-992424 Share on other sites More sharing options...
JonasPHPgutt Posted January 10, 2010 Author Share Posted January 10, 2010 Does it looks wrong? Quote Link to comment https://forums.phpfreaks.com/topic/187975-help-coding-please-look/#findComment-992425 Share on other sites More sharing options...
teamatomic Posted January 10, 2010 Share Posted January 10, 2010 I think the ChromeDomeMufflerBearing function is not quite right. Otherwise it all looks like PHP code. HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/187975-help-coding-please-look/#findComment-992431 Share on other sites More sharing options...
JonasPHPgutt Posted January 10, 2010 Author Share Posted January 10, 2010 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/187975-help-coding-please-look/#findComment-992435 Share on other sites More sharing options...
oni-kun Posted January 10, 2010 Share Posted January 10, 2010 I think the ChromeDomeMufflerBearing function is not quite right. Otherwise it all looks like PHP code. HTH Teamatomic Rofl. Anyway, OP, I'd recommend you pick an indent style and stick to it. http://en.wikipedia.org/wiki/Indent_style Your code is very messy. But there's nothing we can tell you, it's not our code, It's sort of hard to sift through it when we don't know how it works. It's so general. Quote Link to comment https://forums.phpfreaks.com/topic/187975-help-coding-please-look/#findComment-992437 Share on other sites More sharing options...
Maq Posted January 11, 2010 Share Posted January 11, 2010 Hello, I am currently creating an online text based game and I am wondering, what is wrong with this code: What made you ask this question? When developing, you should turn on error reporting and set to max: ini_set ("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/187975-help-coding-please-look/#findComment-992496 Share on other sites More sharing options...
JonasPHPgutt Posted January 11, 2010 Author Share Posted January 11, 2010 I did as you say and I got the error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /usr/export/www/hosting/mafiaverden/_include-config.php on line 22 Quote Link to comment https://forums.phpfreaks.com/topic/187975-help-coding-please-look/#findComment-993060 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.