Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 18
  1. #1
    Join Date
    Mar 2006
    Location
    Scotland
    Posts
    1,012
    Tokens
    175

    Latest Awards:

    Default Non Submitting Form

    Anyone gimme some help? This is my code

    PHP Code:
    <? 
    ob_start
    (); 
    include(
    "config.php"); 
    if (
    $logged[username]) 

    if(!
    $_POST[auction])



    echo (
    "<div align=\"center\"><p><b>Add A New Auction</b><br/>
    You are logged in as 
    $logged[username].</p>


    <form method=\"POST\">
    <p>Auction Name:<br/>
    <input type=\"text\" size=\"40\" maxlength=\"70\" name=\"aname\" ><br /><br />

    Time Limit (days):<br/>
    <input type=\"text\" size=\"40\" maxlength=\"70\" name=\"timel\" ><br/><br/>

    Category:<br/>
    <select name=\"category\" id=\"type\" width=\"40\" style=\"border: 1px solid grey;\">

    <option>Rares</option>
    <option>Super Rares</option>
    <option>Posters</option>
    <option>Plants</option>
    <option>Other</option>
    </select><br /><br />

    Starting Price:<br/>
    <input type=\"text\" size=\"40\" maxlength=\"70\" name=\"sprice\" ><br /><br />

    Buy It Now Price:<br/>
    <input type=\"text\" size=\"40\" maxlength=\"70\" name=\"bin\" ><br /><br />

    Item Description:<br/>
    <input type=\"text\" size=\"40\" name=\"desc\" style=\"height: 200px;\"><br /><br />

    <input type=\"submit\" name=\"auction\" value=\"Submit\"></form> "
    );

    }else {
    $aname htmlspecialchars($_POST[aname]); 
    $category htmlspecialchars($_POST[category]); 
    $sprice htmlspecialchars($_POST[sprice]); 
    $bin htmlspecialchars($_POST[bin]); 
    $desc htmlspecialchars($_POST[disc]); 
    $timel htmlspecialchars($_POST[timel]);
    // the above lines get rid of all html. 
    echo ("$_GET[user] you have posted a new auction. Please wait for our Administrators to verify it."); 
    $query mysql_query("INSERT INTO auction (username, aname, category, sprice, bin, desc, timel) VALUES ($logged[username]$aname$category$sprice$bin$desc$timel"); 
    // updates the information in the database. 

    }
    else {
    echo (
    "Your not logged in.");
    }

    ?>
    Thanks for any help.


    You don't like me
    Chances are I don't like you.

  2. #2
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by RichardKnox View Post
    Anyone gimme some help? This is my code

    PHP Code:
    <? 
    ob_start
    (); 
    include(
    "config.php"); 
    if (
    $logged[username]) 

    if(!
    $_POST[auction])

     
     
    echo (
    "<div align=\"center\"><p><b>Add A New Auction</b><br/>
    You are logged in as 
    $logged[username].</p>
     
     
    <form method=\"POST\">
    <p>Auction Name:<br/>
    <input type=\"text\" size=\"40\" maxlength=\"70\" name=\"aname\" ><br /><br />
     
    Time Limit (days):<br/>
    <input type=\"text\" size=\"40\" maxlength=\"70\" name=\"timel\" ><br/><br/>
     
    Category:<br/>
    <select name=\"category\" id=\"type\" width=\"40\" style=\"border: 1px solid grey;\">
     
    <option>Rares</option>
    <option>Super Rares</option>
    <option>Posters</option>
    <option>Plants</option>
    <option>Other</option>
    </select><br /><br />
     
    Starting Price:<br/>
    <input type=\"text\" size=\"40\" maxlength=\"70\" name=\"sprice\" ><br /><br />
     
    Buy It Now Price:<br/>
    <input type=\"text\" size=\"40\" maxlength=\"70\" name=\"bin\" ><br /><br />
     
    Item Description:<br/>
    <input type=\"text\" size=\"40\" name=\"desc\" style=\"height: 200px;\"><br /><br />
     
    <input type=\"submit\" name=\"auction\" value=\"Submit\"></form> "
    );
     
    }else {
    $aname htmlspecialchars($_POST[aname]); 
    $category htmlspecialchars($_POST[category]); 
    $sprice htmlspecialchars($_POST[sprice]); 
    $bin htmlspecialchars($_POST[bin]); 
    $desc htmlspecialchars($_POST[disc]); 
    $timel htmlspecialchars($_POST[timel]);
    // the above lines get rid of all html. 
    echo ("$_GET[user] you have posted a new auction. Please wait for our Administrators to verify it."); 
    $query mysql_query("INSERT INTO auction (username, aname, category, sprice, bin, desc, timel) VALUES ($logged[username]$aname$category$sprice$bin$desc$timel"); 
    // updates the information in the database. 

    }
    else {
    echo (
    "Your not logged in.");
    }
     
    ?>
    Thanks for any help.

    Heya. It would've helped if you told us the error. Anyway the problem is...

    You have said

    if(!$_POST[auction])

    ??

    You have not named your form...

    <form method=\"POST\"> <----- SEE. The server doesn't know thats the auction form ;P

    Heres the edited code:

    PHP Code:
    <? 
    ob_start
    (); 
    include(
    "config.php"); 
    if (
    $logged[username]) 

    if(!
    $_POST[auction])

     
     
    echo (
    "<div align=\"center\"><p><b>Add A New Auction</b><br/>
    You are logged in as 
    $logged[username].</p>
     
     
    <form method=\"POST\" name=\"auction\">
    <p>Auction Name:<br/>
    <input type=\"text\" size=\"40\" maxlength=\"70\" name=\"aname\" ><br /><br />
     
    Time Limit (days):<br/>
    <input type=\"text\" size=\"40\" maxlength=\"70\" name=\"timel\" ><br/><br/>
     
    Category:<br/>
    <select name=\"category\" id=\"type\" width=\"40\" style=\"border: 1px solid grey;\">
     
    <option>Rares</option>
    <option>Super Rares</option>
    <option>Posters</option>
    <option>Plants</option>
    <option>Other</option>
    </select><br /><br />
     
    Starting Price:<br/>
    <input type=\"text\" size=\"40\" maxlength=\"70\" name=\"sprice\" ><br /><br />
     
    Buy It Now Price:<br/>
    <input type=\"text\" size=\"40\" maxlength=\"70\" name=\"bin\" ><br /><br />
     
    Item Description:<br/>
    <input type=\"text\" size=\"40\" name=\"desc\" style=\"height: 200px;\"><br /><br />
     
    <input type=\"submit\" name=\"auction\" value=\"Submit\"></form> "
    );
     
    }else {
    $aname htmlspecialchars($_POST[aname]); 
    $category htmlspecialchars($_POST[category]); 
    $sprice htmlspecialchars($_POST[sprice]); 
    $bin htmlspecialchars($_POST[bin]); 
    $desc htmlspecialchars($_POST[disc]); 
    $timel htmlspecialchars($_POST[timel]);
    // the above lines get rid of all html. 
    echo ("$_GET[user] you have posted a new auction. Please wait for our Administrators to verify it."); 
    $query mysql_query("INSERT INTO auction (username, aname, category, sprice, bin, desc, timel) VALUES ($logged[username]$aname$category$sprice$bin$desc$timel"); 
    // updates the information in the database. 

    }
    else {
    echo (
    "Your not logged in.");
    }
     
    ?>
    There you go

  3. #3
    Join Date
    Oct 2006
    Posts
    33
    Tokens
    0

    Default

    You also need a action= in the <form> part.

    it needs to know where to post it too:

    <form method=\"POST\" name=\"auction\" action=\"page.php\">

    Just change the page.php part, to the namke of this page.

    and you will also want a hidden field in the form, so that once they have posted it, the $auction, variable is set up, so the second time round it skips the form, and does the sql stuff.

    (hope that made sense)

    Primal
    Last edited by primal; 20-10-2006 at 01:13 PM.

  4. #4
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    693
    Tokens
    0

    Default

    Quote Originally Posted by J-Rap View Post
    Heya. It would've helped if you told us the error. Anyway the problem is...

    You have said

    if(!$_POST[auction])

    ??

    You have not named your form...

    <form method=\"POST\"> <----- SEE. The server doesn't know thats the auction form ;P
    Um, no.

    $_POST[auction] refers to <input type="submit" name="auction">

    Does the form go back to the form? (once submitted), or load a blank page? Or not perform the mysql query. Be specifc please.
    XHTML, CSS, AJAX, JS, php, MySQL.

    --

    HxF moderators can't read timestamps.

  5. #5
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    Very sorry. Didn't notice it. I think they should try it my way though.

  6. #6
    Join Date
    Oct 2006
    Posts
    33
    Tokens
    0

    Default

    I was assuming that the form goes back on itself. -- so you need the action="nameofpage.php" part in the form header.

    This would make sense, as it checks whether variable AUCTION has a value, if it doews then it shows the page (second visit), if not then it shows the form (first visit).

    Primal
    Last edited by primal; 20-10-2006 at 09:19 PM.

  7. #7
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    Also i would've thoght that u'd need to name the form in the opening tag.
    Because u surely cant use $_POST[username] etc. when u define name in submit..
    Ur just naming the submit button?

  8. #8
    Join Date
    Nov 2004
    Location
    HabboWeb FM Offices
    Posts
    3,019
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Heinous View Post
    Um, no.

    $_POST[auction] refers to <input type="submit" name="auction">

    Does the form go back to the form? (once submitted), or load a blank page? Or not perform the mysql query. Be specifc please.
    I think he is right cos what I have heard from Joe he can do nearly anythin.. And believe me, he probs can

  9. #9
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    lol. Well i never do it that way. U probs can do it his way. I dunno

  10. #10
    Join Date
    Oct 2006
    Posts
    33
    Tokens
    0

    Default

    Ok let me break it down.

    The name of the form is unimportant. Basically this part:

    action="page.php"

    tell the system where to send the variables. (You could have 5 forms on the page all with the same name, its doesnt matter)

    Looking at your script it seems that it first look at a variable AUCTION, which if not present loads the form, and if it is present skips the form and does the rest.

    This means you need to ahve a hidden field on your form of name AUCTION. So when the form is sent, then the next time the AUCTION variable has been set, and it skips the form this time, and does the rest.

    goodLuck, hope it s working now.

    Primal

Page 1 of 2 12 LastLast

Posting Permissions

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