Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2006
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow ---Storing on the fly images---

    Hi

    I have a script that lets users pick an image and add text to it using this php script:

    PHP Code:
    <?php
    header
    ("Content-type: image/jpeg");

    $name stripslashes($_GET['name']);

    $size stripslashes($_GET['size']);

    $centre stripslashes($_GET['centre']);

    $font 'images/sig_maker/fonts/'.stripslashes($_GET['font']).'.ttf';

    $fontcolor['r'] = stripslashes($_GET['color_r']); // font color - RED

    $fontcolor['g'] = stripslashes($_GET['color_g']); // font color - GREEN

    $fontcolor['b'] = stripslashes($_GET['color_b']); // font color - BLUE

    $lines stripslashes($_GET['lines']);

    function 
    arrow($im$x1$y1$x2$y2$alength$awidth$color){
    ///

    }

    if(
    is_numeric($_GET['color']) && $_GET['color'] >= '1' && $_GET['color'] <= '54')
    {
        
    $bgpic 'images/sig_maker/' $_GET['color'] . '.jpeg';
    }


    $im imagecreatefromjpeg($bgpic);

    //Calculate, the centre:

    for(;;){

    list(
    $image_width$image_height) = getimagesize($bgpic);
    list(
    $left_x, , $right_x) = imagettfbbox($size0$font$name);
    $text_width $right_x $left_x;
    if(
    $image_width $text_width+5){

    break;

    }

    $size $size .5;
    if(
    $size == 1){
    die(
    'Script not responding to decreasing font size, in other words: try using less letters.');
    }

    }
    $hpadding = ($image_width $text_width)/2;
    $vpadding = ($image_height/2);

    $textcolor imagecolorresolve($im$fontcolor['r'], $fontcolor['g'], $fontcolor['b']);
    if(
    $centre== 'y'){

    imagettftext($im$size0$hpadding,$vpadding$textcolor$font$name);

    }else{

    imagettftext($im$size$angle$x$y$textcolor$font$name);

    }

    imagegif($im);
    imagedestroy($im);
    ?>

    This works fine, however I want to automatically save each image that is created to a Mysql table and show the last 5 images created. I dont want to keep the images stored in the Mysql forever, just until 5 new sigs have been created.

    I have very basic knowledge of php and no knowledge of Mysql except a few tutorials i have read.

    So far i have created a table called sig and have fields in it that the image uses (i.e. $name, $font, $size etc and an ID field with increment set to 0??? and also primary?) I did this because when you create an image the url looks like this...

    Code:
    http://gamesigs.co.uk/testgenerator.php?color=25&name=your+text+here&centre=y&x=2&y=30&angle=0&font=unreal&size=25&select=255%2C255%2C255&color_r=255&color_g=255&color_b=255&submit=Create+My+Sig%21
    and i thought if i could save these variables when a user submits the form it could work. Any way I'm completely clueless

    By the way if you want to see my site here's the address: www.gamesigs.co.uk

    PLEASE HELP!!!
    Digi.
    Visit Gamesigs.co.ukto create your own personalised signature using our generator,

  • #2
    New Coder
    Join Date
    Jun 2006
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok i have had an attempt but it aint worked. can you tell me why?

    PHP Code:
    <?php
    $user
    ="joshuacottom_db";
    $password=" ";
    $database="joshuacottom_db";

    $color=$_POST['color'];
    $name=$_POST['name'];
    $centre=$_POST['centre'];
    $size=$_POST['size'];
    $x=$_POST['x'];
    $y=$_POST['y'];
    $angle=$_POST['angle'];
    $font=$_POST['font'];
    $color_r=$_POST['color_r'];
    $color_g=$_POST['color_g'];
    $color_b=$_POST['color_b'];

    mysql_connect('db4.awardspace.com','joshuacottom_db',' ';
    @
    mysql_select_db($database) or die( "Unable to select database");

    $query "INSERT INTO sig VALUES ('','color','$name','$centre','$size','$x','$y','$angle','$font','','$color_r','$color_g','$color_b')";
    mysql_query($query);

    mysql_close();

    //End of database stuff

    header("Content-type: image/jpeg");

    $name stripslashes($_GET['name']);

    $size stripslashes($_GET['size']);

    $centre stripslashes($_GET['centre']);

    $font 'images/sig_maker/fonts/'.stripslashes($_GET['font']).'.ttf';

    $fontcolor['r'] = stripslashes($_GET['color_r']); // font color - RED

    $fontcolor['g'] = stripslashes($_GET['color_g']); // font color - GREEN

    $fontcolor['b'] = stripslashes($_GET['color_b']); // font color - BLUE

    $lines stripslashes($_GET['lines']);

    function 
    arrow($im$x1$y1$x2$y2$alength$awidth$color){
    ///

    }

    if(
    is_numeric($_GET['color']) && $_GET['color'] >= '1' && $_GET['color'] <= '54')
    {
        
    $bgpic 'images/sig_maker/' $_GET['color'] . '.jpeg';
    }


    $im imagecreatefromjpeg($bgpic);

    //Calculate, the centre:

    for(;;){

    list(
    $image_width$image_height) = getimagesize($bgpic);
    list(
    $left_x, , $right_x) = imagettfbbox($size0$font$name);
    $text_width $right_x $left_x;
    if(
    $image_width $text_width+5){

    break;

    }

    $size $size .5;
    if(
    $size == 1){
    die(
    'Script not responding to decreasing font size, in other words: try using less letters.');
    }

    }
    $hpadding = ($image_width $text_width)/2;
    $vpadding = ($image_height/2);

    $textcolor imagecolorresolve($im$fontcolor['r'], $fontcolor['g'], $fontcolor['b']);
    if(
    $centre== 'y'){

    imagettftext($im$size0$hpadding,$vpadding$textcolor$font$name);

    }else{

    imagettftext($im$size$angle$x$y$textcolor$font$name);

    }

    imagegif($im);
    imagedestroy($im);

    //show info

    $username="joshuacottom_db";
    $password=" ";
    $database="joshuacottom_db";

    mysql_connect('db4.awardspace.com','joshuacottom_db',' ');
    @
    mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT * FROM sig";
    $result=mysql_query($query);

    $num=mysql_numrows($result);

    mysql_close();

    echo 
    "<b><center>Last Signature</center></b><br><br>";

    $i=0;
    while (
    $i $num) {
    ?>
    <imgsrc="http://gamesigs.co.uk/testcreation.php?<? echo" $color=mysql_result($result,$i,"color");&$name=mysql_result($result,$i,"name");&$centre=mysql_result($result,$i,"centre");&$size=mysql_result($result,$i,"size");&$x=mysql_result($result,$i,"x");&$y=mysql_result($result,$i,"y");&$angle=mysql_result($result,$i,"angle");&$font=mysql_result($result,$i,"font");&$color_r=mysql_result($result,$i,"color_r");&$color_g=mysql_result($result,$i,"color_g");&$color_b=mysql_result($result,$i,"color_b")";?>" alt="the last sig created"

    <?
    $i
    ++;
    }
    mysql_close();
    ?>
    Visit Gamesigs.co.ukto create your own personalised signature using our generator,


  •  

    Posting Permissions

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