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 11

Thread: PHP form help

  1. #1
    Join Date
    Apr 2008
    Posts
    36
    Tokens
    0

    Default PHP form help

    hi well for my website i made an avatar and i want it to be used as an advertisement thing but the people who use it will be able to put their names on the avatar and i've done the code for it etc

    i've got one page called index.php with a form in where someone can enter something into the box and i've got another page called avatar.php where i have the php code using $_GET to get the box name from the form and printing the text onto the image

    what i want to do is stop it from redirecting to another page but have it so that when you click the button on the form the avatar appears below the form instead

    the code for the index.php is here:

    Code:
    <html>
    <body bgcolor="grey">
    <center>
    <form method="get" action="avatar.php">
    Your Name: <input type="text" name="yourname"/>
    <input type="submit" value="Get Avatar"/>
    </form>
    </body>
    </html>

  2. #2
    Join Date
    Nov 2007
    Location
    London
    Posts
    1,577
    Tokens
    36

    Latest Awards:

    Default

    Quote Originally Posted by Rent-a-car View Post
    hi well for my website i made an avatar and i want it to be used as an advertisement thing but the people who use it will be able to put their names on the avatar and i've done the code for it etc

    i've got one page called index.php with a form in where someone can enter something into the box and i've got another page called avatar.php where i have the php code using $_GET to get the box name from the form and printing the text onto the image

    what i want to do is stop it from redirecting to another page but have it so that when you click the button on the form the avatar appears below the form instead

    the code for the index.php is here:

    Code:
    <html>
    <body bgcolor="grey">
    <center>
    <form method="get" action="avatar.php">
    Your Name: <input type="text" name="yourname"/>
    <input type="submit" value="Get Avatar"/>
    </form>
    </body>
    </html>
    Code:
    <html>
    <body bgcolor="grey">
    <center>
    <form method="get" action="index.php">
    Your Name: <input type="text" name="yourname"/>
    <input type="submit" value="Get Avatar"/>
    </form>
    <? if($_GET["yourname"]){ ?>
    <br />
    avatar.php coding here
    <? } ?>
    </body>
    </html>
    I think that's what you're after? When they submit the form, the page will refresh and it will show their avatar below. Note, I've put in a <br /> so that there will be a gap after the submit button. Put in your avatar.php coding where I said so that it does the code and I presume, if your coding works, shows their image
    Kind Regards,

    Guy
    __________________

    Since 2007. Unbelievable Uptime. Web hosting, resellers, master resellers, linux VPS, windows VPS, shoutcasts, at the lowest prices on the net.
    Tech-Hosts.co.uk.


  3. #3
    Join Date
    Apr 2008
    Posts
    36
    Tokens
    0

    Default

    Hey thanks for the help yes its the exact thing I want but I'm having a little trouble, because when I click the get avatar button it gives me an error saying headers have already been sent

  4. #4
    Join Date
    Nov 2007
    Location
    London
    Posts
    1,577
    Tokens
    36

    Latest Awards:

    Default

    Quote Originally Posted by Rent-a-car View Post
    Hey thanks for the help yes its the exact thing I want but I'm having a little trouble, because when I click the get avatar button it gives me an error saying headers have already been sent
    Try closing/reopening your browser? I think that might work - even though it sounds stupid.
    Kind Regards,

    Guy
    __________________

    Since 2007. Unbelievable Uptime. Web hosting, resellers, master resellers, linux VPS, windows VPS, shoutcasts, at the lowest prices on the net.
    Tech-Hosts.co.uk.


  5. #5
    Join Date
    Apr 2008
    Posts
    36
    Tokens
    0

    Default

    Warning: Cannot modify header information - headers already sent by (output started at /home/sjans/public_html/avatar/index.php:8) in /home/sjans/public_html/images/index.php on line 11
    ‰PNG ��� IHDR��^������WK��;IDATxœKHTQ™QQ0ŠRc,1 `zPP$Q cSQ‰F(!BEQRD[_k‘%.„‚ l5}Œ;98g€8pppp#1I�Hhzmz|EJul‹ cš‹uŽL:f-@Vj™‹Kb›@ƒ�'‚tl+w|�x 1#›ld�*M4!4f-C;€ҮnjŽvmtWU9jx›9Œ]KG/J<V7›mwU•�$8�énd!„!C2}&8f 3^–buy=‘Ͷ‚m�œ1‘tw>€†#E#s|D@ֲ(œ 1vƒ.LkAR=”žΝx_a3f6�|=34…l)Rœv GQۼ\ŠQᨮ˜Y€}W[w6›mq';W"66ˆRTI����IENDB`‚

    and the browser thing didn't work

    Code:
    header("Content-type: image/png");
    thats line 11
    Last edited by Rent-a-car; 03-04-2008 at 06:50 PM.

  6. #6
    Join Date
    Aug 2005
    Location
    London
    Posts
    9,773
    Tokens
    146

    Latest Awards:

    Default

    PHP Code:
    <html>
    <body bgcolor="grey">
    <center>
    <?php
    //Put all your GET variables here
    if($_GET['yourname']) {
    //Your GD libary Code goes here (The output)
    }
    else {
    ?>
    <!-- The actual Form -->
    <form method="get" action="avatar.php">
    Your Name: <input type="text" name="yourname"/> <br />
    <input type="submit" value="Get Avatar"/>
    <!-- End of the Form -->
    <?
    }
    ?>
    </center>
    </body>
    </html>
    .

  7. #7
    Join Date
    Apr 2008
    Posts
    36
    Tokens
    0

    Default

    Okay i got past the headers already sent error with your code --ss-- but now I'm gettign another error saying that

    "The image http://site.com/avatar/ cannot be displayed, because it contains errors."

  8. #8
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    You can't output data, then set headers.

    Your going to need to make a seperate file with the GD info.

    Example:

    PHP Code:
    <?php
    header
    ("Content-type: image/png");
    $text $_GET["text"];

    // GD stuff;
    ?>
    and

    PHP Code:
    <html>
    <body bgcolor="grey">
    <center>
    <!-- The actual Form -->
    <form method="get" action="avatar.php">
    Your Name: <input type="text" name="yourname"/> <br />
    <input type="submit" value="Get Avatar"/>
    <!-- End of the Form -->

    <img src="otherfile.php?text=<?php echo $_GET["yourname"]; ?>" />
    </center>
    </body>
    </html>

  9. #9
    Join Date
    Apr 2008
    Posts
    36
    Tokens
    0

    Default

    When I click Get Avatar it still goes onto the other page instead of refreshing the current page
    Last edited by Rent-a-car; 03-04-2008 at 08:40 PM.

  10. #10
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    well you saved it wrong.

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
  •