Results 1 to 12 of 12

Thread: Submit Form

  1. #1

    Thread Starter
    Lively Member DJ P@CkMaN's Avatar
    Join Date
    Jan 2002
    Location
    Burpengary, Queensland, Australia
    Posts
    95

    Submit Form

    hey all,

    sorry for the newb question but my host has global_variables OFF and for the life of me i cannot get a form to submit

    PHP Code:
    <?
        if(isset($_POST['submit'])):
            $info = isset($_REQUEST['info']) ? $_REQUEST['info'] : '';
            $sql = "UPDATE tourney_admin SET tourney_info='" . addslashes($info) . "'";
            $result = mysql_query($sql)
              or die("Update failed.\n");
            echo "Tournament info has been added/updated.\n";
        else:
    ?>
            <center><b>View/Edit Tourney Info</b>
            <form method="post" action="index.php?action=info">
            <textarea rows="15" name="info" cols="63" value="<?= $row['tourney_info'?>"></textarea><br>
            <input type="image" src="/images/buttons/submit.gif" value="Submit!" alt="Submit!" name="submit">
            </form>
            </center>
    <?
        endif;
    ?>
    can anyone see anything wrong with that and tell me why it wont submit??

    when i click the submit button, all it does is refresh the page, but nothing goes to the database.

    thanks for the help
    There's something I've noticed in the last year or so...
    Australian's are good at EVERYTHING !!!

  2. #2
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    1| what the hell are you trying to do here:
    PHP Code:
    $info = isset($_REQUEST['info']) ? $_REQUEST['info'] : ''
    ???

    and u could have asked me for help today at school in the comp room, i was bored out of my brain !!!

    2| I like the way you style ur ELSE ENDIF thing's

    my solution: give me a definition of exactly what you want to do and i'll we write that code for you.

  3. #3

    Thread Starter
    Lively Member DJ P@CkMaN's Avatar
    Join Date
    Jan 2002
    Location
    Burpengary, Queensland, Australia
    Posts
    95
    lol, i have no idea what that is, im using it because i get no errors about undefined index and with $info = $_REQUEST['info'] i get errors

    and all im trying to do is get what the user types in the textarea named info to go into my database

    i have never been able to get a form to work and its REALLY pissing me off
    There's something I've noticed in the last year or so...
    Australian's are good at EVERYTHING !!!

  4. #4
    Addicted Member Martin Wilson's Avatar
    Join Date
    Mar 2002
    Location
    :)
    Posts
    236
    FYI:
    PHP Code:
    $info = isset($_REQUEST['info']) ? $_REQUEST['info'] : ''
    That is similar to the vb IIF. If the first part is true, then it returns the second part , else it returns the third part.
    It is just checking if $_REQUEST['info'] is set and return it if it is (wow...4 two letter words beginning in 'i'!).

  5. #5
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    you need a "where" clause in your UPDATE sql statement for 1, unless you want all the records to contain the same info.

    Secondly, you should add .mysql_error() to your die() function as it will give you a more detailed error message.

    Thirdly, check to see if you are connected to the database.

    -Matt
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  6. #6

    Thread Starter
    Lively Member DJ P@CkMaN's Avatar
    Join Date
    Jan 2002
    Location
    Burpengary, Queensland, Australia
    Posts
    95
    ok, so the updated code is this
    PHP Code:
    <?
        if(isset($_POST['submit'])):
            $info = isset($_REQUEST['info']) ? $_REQUEST['info'] : '';
            $sql = "UPDATE tourney_admin SET tourney_info='" . addslashes($info) . "'WHERE id=1";
            $result = mysql_query($sql)
              or die("Update failed.\n");
            echo "Tournament info has been added/updated.\n";
        else:
    ?>
            <center><b>View/Edit Tourney Info</b>
            <form method="post" action="index.php?action=info">
            <textarea rows="15" name="info" cols="63" value="<?= $row['tourney_info'?>"></textarea><br>
            <input type="image" src="/images/buttons/submit.gif" value="Submit!" alt="Submit!" name="submit">
            </form>
            </center>
    <?
        endif;
    ?>
    but i dont have any problems with the database, my problem is the form wont "submit". it just keeps refreshing the page when i click Submit and doesnt acknowledge that the user has entered the information in the form.
    There's something I've noticed in the last year or so...
    Australian's are good at EVERYTHING !!!

  7. #7
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    well, i cant figure out EXACTLY what you want, but i menaged to convert the following code:
    PHP Code:
    <?
        if(isset($_POST['submit']))
            {
            $submit = $_POST['submit'];
            
            
          $sql = "UPDATE tourney_admin SET tourney_info='" . .addslashes($info) . "'WHERE id=1";
          $result = mysql_query($sql) or die("Submit Query Failed");
          
          ECHO "Tournament info has been added/updated.\n";
            } ELSE {
    ?>
            <center><b>View/Edit Tourney Info</b>
            <form method="post" action="index.php?action=info">
            <textarea rows="15" name="info" cols="63" value="<?= $row['tourney_info'?>"></textarea><br>
            <input type="submit" value="Submit!">
            </form>
            </center>
    <?
        }
        unset($submit);
    ?>

  8. #8
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    I notice you have the action for your form set to : index.php?action=info
    I did this once and it caused problems for me, what you should do is make a hidden field to store that value like so:
    <input type="hidden" name="action" value="info" />

    And you need a space between ' and where
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  9. #9

    Thread Starter
    Lively Member DJ P@CkMaN's Avatar
    Join Date
    Jan 2002
    Location
    Burpengary, Queensland, Australia
    Posts
    95
    still nothing, and cpradio, im not exactly sure what your talking about
    There's something I've noticed in the last year or so...
    Australian's are good at EVERYTHING !!!

  10. #10
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    you have this (red area is where I have had a problem in the past):
    <form method="post" action="index.php?action=info">

    I would change that to:
    <form method="post" action="index.php">
    <input type="hidden" name="action" value="info" />

    -Matt
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  11. #11
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    why have action=info if all you are doing is checking for submit? if you want action then do it like this

    PHP Code:
    <?
    switch ($_POST["action"]){

    case "info":

            $info = isset($_POST['info']) ? $_POST['info'] : '';
            $sql = "UPDATE tourney_admin SET tourney_info='" . addslashes($info) . "'WHERE id=1";
            $result = mysql_query($sql)
              or die("Update failed.\n");
            echo "Tournament info has been added/updated.\n";
    break;

    default:
    ?>
            <center><b>View/Edit Tourney Info</b>
            <form method="post" action="index.php?action=info">
            <textarea rows="15" name="info" cols="63" value="<?= $row['tourney_info'?>"></textarea><br>
            <input type="image" src="/images/buttons/submit.gif" value="Submit!" alt="Submit!" name="submit">
            </form>
            </center>
    <?
       }
    ?>
    if you you are not using action then just take it off.

  12. #12
    Member
    Join Date
    Jun 2002
    Posts
    53
    is therea way you can do that straight to your e-mail address?
    Platty rules

Posting Permissions

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



Click Here to Expand Forum to Full Width