Results 1 to 3 of 3

Thread: PHP and form assistance needed.

  1. #1
    Join Date
    Feb 2008
    Posts
    10
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default PHP and form assistance needed.

    Help!!

    Can some one tell me how to hide the default font size in the code below. Curently a user can enter any FONT size they want but I would simply like a default font size and hide the field completely. This is a php script that lets the user preview their desired text in the selected font.

    The part I need to change is in red.
    Thanks in advance.

    $text = stripslashes($_GET['text']);
    $filename = $_GET['filename'];
    $size = $_GET['size'];

    if (isset($_GET['render'])) {
    Header ("Content-type: image/png");
    $fonturl = $fontdir.'/'.$filename;
    $textdims = ImageTTFBBox($size, 0, $fonturl, $text);
    $im = imagecreate ($textdims[2]-$textdims[6]+10, $textdims[3]-$textdims[7]+10);
    $white = ImageColorAllocate ($im, 255, 255, 255);
    $black = ImageColorAllocate ($im, 0, 0, 0);
    ImageTTFText ($im, $size, 0, 0, -$textdims[5], $black, $fonturl, $text);
    ImagePng ($im);
    ImageDestroy ($im);
    die();
    } else {
    ?><HTML>
    <head>
    <title>YakTagz Live Font Previewer</title>
    <style type="text/css"><!--
    body {font-family:georgia, verdana; scrollbar-base-color:white; scrollbar-face-color:black; scrollbar-track-color:white; scrollbar-highlight-color:black; scrollbar-shadow-color:white; scrollbar-darkshadow-color:white; scrollbar-arrow-color:white}
    h1 {font-family: trebuchet ms, verdana}
    a:link, a:visited {color:blue;text-decoration:underline}
    a:active, a:hover {color:red;text-decoration:none}
    --></style>
    </head>
    <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#00ff00" alink="#ff0000">
    <h1 align="center">YakTagz Live Font Previewer</h1>

    <br />
    <div align="center">
    <table><tr><td>
    <form method="get">
    <p>Select Font:
    <select name="filename">
    <?
    foreach ($fontnames as $thisfile => $thisname) {
    print '<option ';
    if ($filename == $thisfile) echo 'selected="selected" ';
    print 'value="' . $thisfile . '">' . $thisname . '</option>' . "\n";
    }
    ?>
    </select>
    </p>
    <p>

    Font size: <input name="size" value="<? if (!$size) echo "52"; else echo $size; ?>" size="2" />


    </p>
    <p>Text to preview:<br /><textarea name="text" cols="25" rows="1"><? if
    (isset($text)) echo $text; ?></textarea></p>
    </td></tr></table>
    <p><input type="submit" value="Preview Yaktag" /></p>
    </form>
    </div><? if (isset($filename) && isset($text)) { ?>

    <center><p>
    <img src="<?
    echo $_SERVER['SCRIPT_NAME']."?render=1&filename=$filename&size=$size&text=".urlencode($text);
    ?>" /></p>
    <? } ?>
    <center>

    The actual page is at www.yaktagz.com/preview.php if you need to see what I'm talking about.

    Thanks in advance.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Code:
    $text = stripslashes($_GET['text']);
    $filename = $_GET['filename'];
    $text = '52';
    if (isset($_GET['render'])) {
    Header ("Content-type: image/png");
    $fonturl = $fontdir.'/'.$filename;
    $textdims = ImageTTFBBox($size, 0, $fonturl, $text);
    $im = imagecreate ($textdims[2]-$textdims[6]+10, $textdims[3]-$textdims[7]+10);
    $white = ImageColorAllocate ($im, 255, 255, 255);
    $black = ImageColorAllocate ($im, 0, 0, 0);
    ImageTTFText ($im, $size, 0, 0, -$textdims[5], $black, $fonturl, $text);
    ImagePng ($im);
    ImageDestroy ($im);
    die();
    } else {
    ?><HTML>
    <head>
    <title>YakTagz Live Font Previewer</title>
    <style type="text/css"><!--
    body {font-family:georgia, verdana; scrollbar-base-color:white; scrollbar-face-color:black; scrollbar-track-color:white; scrollbar-highlight-color:black; scrollbar-shadow-color:white; scrollbar-darkshadow-color:white; scrollbar-arrow-color:white}
    h1 {font-family: trebuchet ms, verdana}
    a:link, a:visited {color:blue;text-decoration:underline}
    a:active, a:hover {color:red;text-decoration:none}
    --></style>
    </head>
    <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#00ff00" alink="#ff0000">
    <h1 align="center">YakTagz Live Font Previewer</h1>
    
    <br />
    <div align="center">
    <table><tr><td>
    <form method="get">
    <p>Select Font:
    <select name="filename">
    <?
    foreach ($fontnames as $thisfile => $thisname) {
    print '<option ';
    if ($filename == $thisfile) echo 'selected="selected" ';
    print 'value="' . $thisfile . '">' . $thisname . '</option>' . "\n";
    }
    ?>
    </select>
    </p>
    <p>
    
    Font size: 52
    
    
    </p>
    <p>Text to preview:<br /><textarea name="text" cols="25" rows="1"><? if
    (isset($text)) echo $text; ?></textarea></p>
    </td></tr></table>
    <p><input type="submit" value="Preview Yaktag" /></p>
    </form>
    </div><? if (isset($filename) && isset($text)) { ?>
    
    <center><p>
    <img src="<?
    echo $_SERVER['SCRIPT_NAME']."?render=1&filename=$filename&size=$size&text=".urlencode($text);
    ?>" /></p>
    <? } ?>
    <center>
    Jeremy | jfein.net

  3. #3
    Join Date
    Feb 2008
    Posts
    10
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Thanks for the attempt but it doesn't appear to be working.



    Edit,

    spent some time working with it and added a form type="hidden".

    This took care of it.

    here's my working page. www.yaktagz.com/preview.php

    Now if you can help me do a font color selection item, that would be great!
    Last edited by redrubi; 02-28-2008 at 11:54 PM.

Bookmarks

Posting Permissions

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