Jump to content

Password Protect A Registration


ChidoriSoul
 Share

Recommended Posts

It's just a simple if structure. You put your form processing code into the allow section, and you put an error message or something into the deny section. Have you used if statements? Do you just copy and paste code you see and expect it to work?

Edited by justsomeguy
Link to comment
Share on other sites

Register

<?php// Connects to your Databasemysql_connect("fdb1.awardspace.com", "chidorisoul_sh", "******") or die(mysql_error());mysql_select_db("chidorisoul_sh") or die(mysql_error());//This code runs if the form has been submittedif (isset($_POST['submit'])) {//This makes sure they did not leave any fields blankif (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {die('You did not complete all of the required fields');}// checks if the username is in useif (!get_magic_quotes_gpc()) {$_POST['username'] = addslashes($_POST['username']);}$usercheck = $_POST['username'];$check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'")or die(mysql_error());$check2 = mysql_num_rows($check);//if the name exists it gives an errorif ($check2 != 0) {die('Sorry, the username '.$_POST['username'].' is already in use.');}// this makes sure both passwords entered matchif ($_POST['pass'] != $_POST['pass2']) {die('Your passwords did not match. ');}// here we encrypt the password and add slashes if needed$_POST['pass'] = md5($_POST['pass']);if (!get_magic_quotes_gpc()) {$_POST['pass'] = addslashes($_POST['pass']);$_POST['username'] = addslashes($_POST['username']);}// now we insert it into the database$insert = "INSERT INTO users (username, password)VALUES ('".$_POST['username']."', '".$_POST['pass']."')";$add_member = mysql_query($insert);?><h1>Registered!</h1>You have successfuly registered, you may now <a href="login.php">login</a>.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>  <head>    <title>Register</title><style type="text/css"><!--body,td,th {    color: #FF0000;    font-family: Tahoma;    font-size: 9px;    font-weight: bold;}body {    background-color: #000000;}.thead {background: #302226;border: 1px solid #000000;border-bottom: 0px;text-align: center;vertical-align: middle;height: 15px;}.tnav {background: #302226;border: 1px solid #000000;border-bottom: 0px;text-align: center;height: 15px;}.tnav2 {background: #302226;border: 1px solid #000000;border-bottom: 1px solid black;text-align: center;height: 15px;}.news {background: #302226;border: 1px solid #000000;border-bottom: 1px solid #000000;text-align: center;height: 15px;}.banner {border-bottom: 0px;}.dis {border-top: 0px;}.con {border-top: 0px;border-bottom: 0px;}.party {background: #302226;border: 1px solid #000000;border-bottom: 0px;text-align: center;height: 25px;}a:link {    color: #990000;    text-decoration: none;}a:visited {    text-decoration: none;    color: #990000;}a:active {    text-decoration: none;    color: #FFFFFF;}.style1 {color: #FFFFFF}--></style><body><table align="center" width="200" height="247" border="0" cellpadding="0" cellspacing="0" bordercolor="#FF0000">  <tr>    <td align="left" valign="top"><table width="802" height="120" border="1" cellpadding="0" cellspacing="0" bordercolor="#FF0000" class="banner">      <tr>        <th background="http://i286.photobucket.com/albums/ll84/ChidoriSoul/BetterAsteroidBanner.png?t=1243111409" scope="col"> </th>      </tr>    </table>      <table width="802" height="120" border="1" cellpadding="0" cellspacing="0" bordercolor="#FF0000" class="con">        <tr><!--- Ads --><div style="text-align: center"><script type="text/javascript"><!--google_ad_client = "pub-4468899317544238";/* TPARPG */google_ad_slot = "0388012058";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div><!--- End of Ads --><!--- Left Nav -->                   <th width="122" align="center" valign="top" bgcolor="#302226" scope="row">                    <div class="thead style1" id="thead"> <font color='limegreen'>General Options</font> </div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/home.php"><font color='blue'>Home</font></a></div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/register.php"><font color='blue'><del>Register</del></font></a></div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/login.php"><font color='blue'><del>Login</del></font></a></div>                    <div class="thead style1" id="thead"> <font color='limegreen'>Miscellaneous</font> </div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/about.php"><font color='blue'>About TPA</font></a></div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/storyline.php"><font color='blue'>Storyline</font></a></div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/chatbox.php"><font color='blue'>Chatbox</font></a></div>          <div class="tnav"> <a href="http://www.punbb-hosting.com/forums/TPA_Forums/index.php"><font color='blue'>Forum</font></a></div>                    <div class="thead style1" id="thead"> <font color='limegreen'>Statistics</font> </div>          <div class="tnav"> <font color='blue'>Total Users: 0</font></div>                     </th><!--- End Of Left Nav --><!--- Start Content --> <th width="520" align="center" valign="top" bgcolor="#302226" scope="row">          <div class="news" id="thead"> Index </div>                   <br /><?php}else{?><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><table border="0"><tr><td>Username:</td><td><input type="text" name="username" maxlength="60"></td></tr><tr><td>Password:</td><td><input type="password" name="pass" maxlength="10"></td></tr><tr><td>Confirm Password:</td><td><input type="password" name="pass2" maxlength="10"></td></tr><tr><td>Enter Code (Get from Shadow):</td><td><?phpif ($_POST['code'] == 'Holo'){  // allow}else{  // deny}?><input type="text" name="code" maxlength="4"></td></tr><tr><th colspan=2><input type="submit" name="submit" value="Register"></th></tr> </table></form><?php}?><!--- End Content --><!--- Right Nav -->                   <th width="122" align="center" valign="top" bgcolor="#302226" scope="row">                    <div class="thead style1" id="thead"> <font color='limegreen'>General Options</font> </div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/home.php"><font color='blue'>Home</font></a></div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/register.php"><font color='blue'><del>Register</del></font></a></div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/login.php"><font color='blue'><del>Login</del></font></a></div>                     <div class="thead style1" id="thead"> <font color='limegreen'>Miscellaneous</font> </div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/about.php"><font color='blue'>About TPA</font></a></div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/storyline.php"><font color='blue'>Storyline</font></a></div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/chatbox.php"><font color='blue'>Chatbox</font></a></div>          <div class="tnav"> <a href="http://www.punbb-hosting.com/forums/TPA_Forums/index.php"><font color='blue'>Forum</font></a></div>                    <div class="thead style1" id="thead"> <font color='limegreen'>Statistics</font> </div>          <div class="tnav"> <font color='blue'>Total Users: 0</font></div>                     </th><!--- End Of Right Nav --><!--- Disclaimer --><table width="765" height="45" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FF0000" "backgroundcolor="#302226" class="dis"><tr>    <td align="center" valign="top"><strong>Disclaimer</strong><br />   The Pokémon Asteroid RPG is © owned and coded by Shadow. All sprites are Copyrighted 2009 Pokémon © Nintendo, Game Freak, Creatures Ink all rights reserved.The Asteroid RPG! is not affiliated with the organizations listed above or any other organizations that have co-operated or are co-operating in the programming or making of Pokémon. The images are copyright of their respective owners. This RPG is best viewed with Firefox. </td>  </tr></table></a></div><!--- End of Disclaimer -->

Link to comment
Share on other sites

<tr><td>Enter Code (Get from Shadow):</td><td><?phpif ($_POST['code'] == 'Holo'){// allow}else{// deny}?><input type="text" name="code" maxlength="4"></td></tr><tr><th colspan=2><input type="submit" name="submit" value="Register"></th></tr> </table></form>

I'm not sure what you're doing here.... what is "shadow" and how does it give them the code?anyway... remove the
<?phpif ($_POST['code'] == 'Holo'){// allow}else{// deny}?>

and then just like you did for your passwords matching:
// this makes sure both passwords entered matchif ($_POST['pass'] != $_POST['pass2']) {die('Your passwords did not match. ');}

in that same area, do this
// this makes sure the code word is rightif ($_POST['code] != "Holo") {die('You entered an incorrect code. ');}

Edited by smerny
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...