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 7 of 7
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Submit button no effect

    Index2.php:
    Code:
    <form method="POST" action="index2.php">
    <tr>
      <td colspan="2">Login:</td>
    
    </tr>
    <tr>
      <td width="250">Username:</td>
      <td width="166"><input type="text" name="user"></td>
    </tr>
    <tr>
      <td>Password:</td>
      <td><input type="password" name="pass"></td>
    </tr>
    <tr>
      <td>Remember:</td>
    
      <td><input type="checkbox" name="remember"></td>
    </tr>
    <tr>
      <td colspan="2"><input type="submit" value="Register" name="subreg"> <input type="submit" value="Login" name="sublogin"></td> 
    </tr>
    </form>
    It does nothing, it also doesn't load the page or anything. Is it supposed to work or am I missing something?

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    It should post to index2.php

    Does that file exist? If so what is it in it?
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New Coder
    Join Date
    Dec 2006
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by _Aerospace_Eng_ View Post
    It should post to index2.php

    Does that file exist? If so what is it in it?
    <?php
    if(isset($_POST['sublogin'])) { echo 'boo'; }
    ?>

    The button does nothing, it doesnt even load index2.php or anything. I also tried just 'echo "boo";' but nothing happens at all.
    Last edited by Ge64; 12-18-2006 at 11:47 AM.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Well you have two submit buttons. I just tested what you have on my local server, pressing the first submit button does nothing because the second submit button is never actually clicked however using the second submit button echos boo.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    New Coder
    Join Date
    Dec 2006
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by _Aerospace_Eng_ View Post
    Well you have two submit buttons. I just tested what you have on my local server, pressing the first submit button does nothing because the second submit button is never actually clicked however using the second submit button echos boo.
    Then maybe it's something else somehow, because I click both buttons and nothing happens at all. I'll re-check what I have

  • #6
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,146
    Thanks
    2
    Thanked 333 Times in 325 Posts
    I tested and this works (both submit buttons.)

    Your first post lists the form code as index2.php and you also posted the second piece of code as index2.php, which file is really named index2.php?
    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.

  • #7
    New Coder
    Join Date
    Dec 2006
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is the entire output of index.php:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <script type="text/javascript" language="javascript">
    var loggedin = 0
    window.onload = function()
    {
    if (loggedin) {
    document.getElementById('login').innerHTML = document.getElementById('logged_in').innerHTML;
    } else {
    document.getElementById('login').innerHTML = document.getElementById('login_form').innerHTML;
    }
    }
    </script>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    
    <body>
    
    <table width="250" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td id="login"></td>
    
      </tr>
      <tr>
        <td id="body">~*body*</td>
      </tr>
      <tr>
        <td><div id="login_form" style="display: none;">
    	<table width="422" border="1" cellspacing="0" cellpadding="0"><form method="POST" action="index2.php">
    <tr>
      <td colspan="2">Login:</td>
    
    </tr>
    <tr>
      <td width="250">Username:</td>
      <td width="166"><input type="text" name="user"></td>
    </tr>
    <tr>
      <td>Password:</td>
      <td><input type="password" name="pass"></td>
    </tr>
    <tr>
      <td>Remember:</td>
    
      <td><input type="checkbox" name="remember"></td>
    </tr>
    <tr>
      <td colspan="2"><input type="submit" value="Register" name="subreg"> <input type="submit" value="Login" name="sublogin"></td> 
    </tr>
    </form></table></div><div id="logged_in" style="display:none;"><p>Logged in as: ~*loggedin_name*</p></div>
    <a href="?action=logout">Log out</a></td>
      </tr>
    </table>
    
    </body>
    
    </html>
    This is index2.php:

    Code:
    <?php
    error_reporting(E_ALL);
    session_start();
    include 'config.php';
    include 'functions.php';
    connectdb();
    if (isset($_GET['action'])) { include 'actions.php'; }
    include 'login.php';
    
    if(isset($_POST['sublogin'])) { echo 'boo'; login(); }
    
    $test1 = "test1";
    $test2 = "test2";
    $test3 = "test3";
    
    $variable_list = array(
    'login_form_properties',
    'login_usernameinput_properties',
    'login_passwordinput_properties',
    'login_rememberinput_properties',
    'login_loginbutton_properties',
    'login_registerbutton_properties',
    'loggedin_name',
    'loggedin',
    
    'test1',
    'test2',
    'test3');
    
    for ($i = 0;$i <= (count($variable_list)-1);$i++) {
    $currentarraykey = '~*' . $variable_list[$i] . '*';
    if (isset(${$variable_list[$i]})) {
    $injectdata[$currentarraykey] = ${$variable_list[$i]};
    }
    }
    
    mysql_close($conn);
    
    echo inject($injectdata,"default");
    
    ?>
    You see, pressing the login button should at least echo boo somewhere, but instead nothing happens. It doesn't even go to index2.php or anything at all.

    Edit: I just tried IE6 and it does boo, but in FFv2 nothing happens?!

    Edit2: I decided to run the output through the html validator, and the problem was the <form> tag cannot be inside the <table> tag. So I switched them and now it works :P
    Last edited by Ge64; 12-19-2006 at 03:12 AM.


  •  

    Posting Permissions

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