Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    due
    due is offline
    New Coder
    Join Date
    May 2006
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    need help with register

    when i insert details it refreshes why?
    PHP Code:
    <html>
    <head>
    <title>War of chaos V2</title>
    <link rel="stylesheet" type="text/css"
    href="css/style.css" />
    </head>
    <body>
    <table border="0">
    <tr>

    <td>
    <form action="login.php" method="post">
        Username: <input name="username" id="username" value="usernamehere" type="text" maxlength="30" /><br />
        Password: <input name="password" id="password"  value="pass" type="password" /><br />
        <input type="submit" value="Log In" /><br />
        <a href="register.php">Register</a><br />
        <a href="forgot.php">Forgot Pass?</a>
      </form>
    </td></tr></table>
    <table border="0" width="100%">
      <tr>
    <th bgcolor="#690000"><center>REGISTER</th></tr></table>
    <?
    include "config.php";
    if(!empty(
    $_POST['lsubmit'])&& (empty($_POST['username'])||empty($_POST['password'])||empty($_POST['rpassword'])||empty($_POST['race'])||empty($_POST['email'])||empty($_POST['remail'])))
    {
            echo 
    "Please Fill Out all fields";
    }
    elseif(!empty(
    $_POST['lsubmit'])) {
            
    $created mysql_query("INSERT INTO users ('username','email','race','password') VALUES( '{$_POST['username']}', '{$_POST['email']}', '{$_POST['race']}', '{$_POST['password']}' )");
            
    // error
    $to      $_POST['email'];
    $subject 'Welcome to War of Chaos V2';
    $message "Welcome to War of chaos v2 Have fun<br> your login info is below<br>Login Info:<br> Username:{$_POST['username']}<br>Password:{$_POST['password']}";
    $headers 'From: admin@warofchaos.cjb.net' "\r\n" .
       
    'Reply-To: ericglazebrook@gmail.com' "\r\n" .
       
    'X-Mailer: PHP/' phpversion();

    mail($to$subject$message$headers);
    echo 
    "MAIL SENT";
    }
    ?>

    <center><form action="">
    <table border="0">
    <tr>
    <td>Username:</td><td><input name="username" type="text"></td></tr>
    <tr><td>Password:</td><td><input name="password" type="password"></td></tr>
    <tr><td>Re-Password:</td><td><input name="rpassword" type="password"></td></tr>
    <tr><td>Race:</td><td><select id="race" name="race">
    <option value="Gods">Gods</option><option value="Slaves">Slaves</option><option value="vampires">Vampires</option><option value="globlins">Globins</option></td></tr>
    <tr><td>Email:</td><td><input name="email" type="text"></td></tr>
    <tr><td>Re-Email:</td><td><input name="remail" type="text"></td></tr>
    <tr><td>Register:</td><td><input name="lsubmit" type="submit" id="lsubmit" value="Register"></td></tr>
    </table>
    </form></center>
    </div>
    <br style="clear:both" />
    <div id="footer" align="center">&copy; War of chaos</div>
    </body>
    </html>
    DUE

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    mre nfo

  • #3
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    2,960
    Thanks
    2
    Thanked 304 Times in 296 Posts
    Your code unconditionally displays the form at the top and the form at the bottom. When you enter information in the bottom form and press the submit button, the target is this same page. This causes the form at the top to be sent to the browser again, the mail(...) code is executed, and the form at the bottom is sent to the browser again.

    If you don't want this to occur, you must add conditional logic around the form code that prevents it from being executed when the form is submitted.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #4
    due
    due is offline
    New Coder
    Join Date
    May 2006
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ok

    so if i did an include would it work?
    DUE

  • #5
    due
    due is offline
    New Coder
    Join Date
    May 2006
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    this is the new one

    PHP Code:
    <html>
    <head>
    <title>War of chaos V2</title>
    <link rel="stylesheet" type="text/css"
    href="css/style.css" />
    </head>
    <body>
    <table border="0">
    <tr>

    <td>
    <form action="login.php" method="post">
        Username: <input name="username" id="username" value="usernamehere" type="text" maxlength="30" /><br />
        Password: <input name="password" id="password"  value="pass" type="password" /><br />
        <input type="submit" value="Log In" name="lsubmit" id="lsubmit" /><br />
        <a href="register.php">Register</a><br />
        <a href="forgot.php">Forgot Pass?</a>
      </form>
    </td></tr></table>
    <table border="0" width="100%">
      <tr>
    <th bgcolor="#690000"><center>REGISTER</th></tr></table>
    <?
    include "config.php";
    if(!empty(
    $_POST['submit'])&& (empty($_POST['username'])||empty($_POST['password'])||empty($_POST['rpassword'])||empty($_POST['race'])||empty($_POST['email'])||empty($_POST['remail'])))
    {
            echo 
    "Please Fill Out all fields";
    }
    elseif(!empty(
    $_POST['submit'])) {
            
    $created mysql_query("INSERT INTO users ('username','email','race','password') VALUES( '{$_POST['username']}', '{$_POST['email']}', '{$_POST['race']}', '{$_POST['password']}' )");
            
    // error
    $to      $_POST['email'];
    $subject 'Welcome to War of Chaos V2';
    $message "Welcome to War of chaos v2 Have fun<br> your login info is below<br>Login Info:<br> Username:{$_POST['username']}<br>Password:{$_POST['password']}";
    $headers 'From: admin@warofchaos.cjb.net' "\r\n" .
       
    'Reply-To: ericglazebrook@gmail.com' "\r\n" .
       
    'X-Mailer: PHP/' phpversion(5);

    mail($to$subject$message$headers);
    echo 
    "MAIL SENT";
    }


    echo 
    "<center><form action=>
    <table border=0>
    <tr>
    <td>Username:</td><td><input name=username type=text></td></tr>
    <tr><td>Password:</td><td><input name=password type=password></td></tr>
    <tr><td>Re-Password:</td><td><input name=rpassword type=password></td></tr>
    <tr><td>Race:</td><td><select id=race name=race>
    <option value=Gods>Gods</option><option value=Slaves>Slaves</option><option value=vampires>Vampires</option><option value=globlins>Globins</option></td></tr>
    <tr><td>Email:</td><td><input name=email type=text></td></tr>
    <tr><td>Re-Email:</td><td><input name=remail type=text></td></tr>
    <tr><td>Register:</td><td><input name=submit type=submit id=submit value=Register></td></tr>
    </table>
    </form></center>"
    ;
    ?>
    </div>
    <br style="clear:both" />
    <div id="footer" align="center">&copy; War of chaos</div> 
    </body>
    </html>
    DUE

  • #6
    due
    due is offline
    New Coder
    Join Date
    May 2006
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    wow new again

    PHP Code:
    <html>
    <head>
    <title>War of chaos V2</title>
    <link rel="stylesheet" type="text/css"
    href="css/style.css" />
    </head>
    <body>
    <table border="0">
    <tr>

    <td>
    <form action="login.php" method="post">
        Username: <input name="username" id="username" value="usernamehere" type="text" maxlength="30" /><br />
        Password: <input name="password" id="password"  value="pass" type="password" /><br />
        <input type="submit" value="Log In" name="lsubmit" id="lsubmit" /><br />
        <a href="register.php">Register</a><br />
        <a href="forgot.php">Forgot Pass?</a>
      </form>
    </td></tr></table>
    <table border="0" width="100%">
      <tr>
    <th bgcolor="#690000"><center>REGISTER</th></tr></table>
    <?
    include "config.php";
    if(!empty(empty(
    $_POST['username'])||empty($_POST['password'])||empty($_POST['rpassword'])||empty($_POST['race'])||empty($_POST['email'])||empty($_POST['remail'])))
    {
            
            echo 
    "<center><form action=>
    <table border=0>
    <tr>
    <td>Username:</td><td><input name=username type=text></td></tr>
    <tr><td>Password:</td><td><input name=password type=password></td></tr>
    <tr><td>Re-Password:</td><td><input name=rpassword type=password></td></tr>
    <tr><td>Race:</td><td><select id=race name=race>
    <option value=Gods>Gods</option><option value=Slaves>Slaves</option><option value=vampires>Vampires</option><option value=globlins>Globins</option></td></tr>
    <tr><td>Email:</td><td><input name=email type=text></td></tr>
    <tr><td>Re-Email:</td><td><input name=remail type=text></td></tr>
    <tr><td>Register:</td><td><input name=submit type=submit id=submit value=Register></td></tr>
    </table>
    </form></center>"
    ;
    }
    if (!empty(
    $_POST['submit'])) {
            echo 
    "Please Fill Out all fields";
    }
    elseif(!empty(
    $_POST['submit'])) {
            
    $created mysql_query("INSERT INTO users ('username','email','race','password') VALUES( '{$_POST['username']}', '{$_POST['email']}', '{$_POST['race']}', '{$_POST['password']}' )");
            
    // error
    $to      $_POST['email'];
    $subject 'Welcome to War of Chaos V2';
    $message "Welcome to War of chaos v2 Have fun<br> your login info is below<br>Login Info:<br> Username:{$_POST['username']}<br>Password:{$_POST['password']}";
    $headers 'From: admin@warofchaos.cjb.net' "\r\n" .
       
    'Reply-To: ericglazebrook@gmail.com' "\r\n" .
       
    'X-Mailer: PHP/' phpversion(5);

    mail($to$subject$message$headers);
    echo 
    "MAIL SENT";
    }



    ?>
    </div>
    <br style="clear:both" />
    <div id="footer" align="center">&copy; War of chaos</div> 
    </body>
    </html>
    DUE


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •