Results 1 to 6 of 6

Thread: hmm, using a form to save to a session, then convert to a .png?

  1. #1
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default hmm, using a form to save to a session, then convert to a .png?

    i'm trying to save text in a form to a session, and use the session to convert it to a .png file but it doesnt seem to work, and i dont know where its messing up.

    this is the form page:
    Code:
    <html>
    <form method="POST" action="http://akwardsaw.hostoi.com/createpic.php">
        <input type="text" name="text" value="text"> 
        <input type="submit" value="Change"> 
    </form>
    </html>
    and the link: here

    here is the file to convert that text to a .png file:
    Code:
    <?php
    $_SESSION['text']=$_POST['text']; 
    session_start();
    
    
    header("Content-type: image/png");
    
    function create($text){
    
    $im = imagecreate(100, 30);
    
    $bg = imagecolorallocate($im, 255, 255, 255);
    $textcolor = imagecolorallocate($im, 0, 0, 255);
    
    imagestring($im, 5, 0, 0, $text, $textcolor);
    
    imagepng($im);
    imagedestroy($im);
    }
    
    if(isset($_SESSION['text']))
    create($_SESSION['text']);
    else {
    $_SESSION['text']="wat";
    create($_SESSION['text']);
    }
    ?>
    here

    making the pic works, but it doesnt save the POST text from the form into a session
    Last edited by Awkwardsaw; 09-14-2009 at 09:37 AM.
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  2. #2
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    This seems to work for me..

    php Code:
    <?php
    session_start();
    header("Content-type: image/png");

    function create($text){

    $im = imagecreate(100, 30);

    $bg = imagecolorallocate($im, 255, 255, 255);
    $textcolor = imagecolorallocate($im, 0, 0, 255);

    imagestring($im, 5, 0, 0, $text, $textcolor);

    imagepng($im);
    imagedestroy($im);
    }

    if(isset($_SESSION['text']))
    create($_SESSION['text']);
    else {
    $_SESSION['text']="wat";
    create($_SESSION['text']);
    }
    ?>

    I also don't think you can post a form to the session array, it's either POST or GET.

  3. #3
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by nielsie95 View Post
    This seems to work for me..

    php Code:
    <?php
    session_start();
    header("Content-type: image/png");

    function create($text){

    $im = imagecreate(100, 30);

    $bg = imagecolorallocate($im, 255, 255, 255);
    $textcolor = imagecolorallocate($im, 0, 0, 255);

    imagestring($im, 5, 0, 0, $text, $textcolor);

    imagepng($im);
    imagedestroy($im);
    }

    if(isset($_SESSION['text']))
    create($_SESSION['text']);
    else {
    $_SESSION['text']="wat";
    create($_SESSION['text']);
    }
    ?>

    I also don't think you can post a form to the session array, it's either POST or GET.
    so, to set it, it would be:

    $_SESSION['text']=$_POST['text'];?
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  4. #4
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    sorry for double post, but how would you set the text in the form as a session? thats my next problem =\ i'v tried
    php Code:
    $_SESSION['text']=$_POST['text'];

    in the form, but meh
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  5. #5
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    You can do that after you've committed the form with POST. So in your PHP script you add that line and in the form you have method="POST".

  6. #6
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    sorry for a semi-grave dig, but when i tried to fix it, it still doesnt save to the session =\

    what other ways can i make this work?
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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