Should be simple problems but im a complete newbie

This is a discussion on "Should be simple problems but im a complete newbie" within the PHP Forum section. This forum, and the thread "Should be simple problems but im a complete newbie are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 2nd, 2007, 13:56
New Member
Join Date: Jan 2007
Location: england
Age: 19
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Should be simple problems but im a complete newbie

HI all.
I have a site called www.gamesigs.co.uk which basically lets people choose an image and put text on it for use in forums as signatures. It works fine but there are 2 things that i would like to do to it that i cant seem to work out.

1) I would like a number to display on the pages that shows how many people have created a signature since. I do not want this so it shows every page hit or unique visit becuase this would give the wrong number. I think it would need to be how many times the submit button was clicked or how many times the sigcreated page was visited. As the sig created page is a variable ie. sigcreated?name=nsdcn,font=ncdc etc. I dont know how to do it.

2) After you click the submit button you are taken to the sig created page. Here it shows your signature in the top left corner of a blank page. I would like for the signature to be placed in tables like a proper page so i could put writing around it etc. However becuase of the way the code is written it prevents me doing this.

Please help me solve these 2 issues.

The script for the sigcreated.php page looks like this:

Code: Select all
<?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'] <= '47')
{
    $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($size, 0, $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, $size, 0, $hpadding,$vpadding, $textcolor, $font, $name);
}else{
imagettftext($im, $size, $angle, $x, $y, $textcolor, $font, $name);
}
imagegif($im);
imagedestroy($im);
?>
Thanks so much!
Reply With Quote

  #2 (permalink)  
Old Jan 3rd, 2007, 22:11
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Should be simple problems but im a complete newbie

I know of two ways. There may be more.

1. Write the image to a file and then you can just use an <img> tag referencing the file path.
2. A little trickier, due to browser differences, is simply to reference the image.php file as the img src, using GET variables as needed.
Reply With Quote
  #3 (permalink)  
Old Jan 4th, 2007, 09:37
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Should be simple problems but im a complete newbie

Is that why IE is giving me troubles with the <img> tag with a .php in the src?
Reply With Quote
  #4 (permalink)  
Old Jan 4th, 2007, 12:18
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Should be simple problems but im a complete newbie

Yeah. Unfortunately Apache requires the .php suffix, and some browser versions will not recognize a .php file as a graphic no matter what heading you send. A possible workaround is to play with the server-side config files so that, say, .php.jpg is interpreted as an image.
Reply With Quote
  #5 (permalink)  
Old Jan 4th, 2007, 14:52
Daniel's Avatar
Elite Veteran
Join Date: Sep 2006
Location: The Kingdom of Rabbits
Age: 21
Posts: 2,051
Blog Entries: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Daniel
Re: Should be simple problems but im a complete newbie



Thats very clever - you ought to make it so u can have a tagline as well. Like id put - DanDoughty. Super Moderator!
Last Blog Entry: Assassin's Creed (Nov 22nd, 2007)
Reply With Quote
  #6 (permalink)  
Old Jan 4th, 2007, 14:56
New Member
Join Date: Jan 2007
Location: england
Age: 19
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Should be simple problems but im a complete newbie

ok right I think i get you know. I have taught myself php so im not great so please explain things in detail and try not to laugh.
Ok heres what ive done (i probably done something really stupid)
I put this img src tag in
Code: Select all
<img src="creation.php"?color=$textcolor&amp;name=$name&amp;centre=$centre&amp;x=$x&amp;y=$y&amp;angle=$angle&amp;font=$font&amp;size=$size&amp;select=255%2C255%2C255&amp;color_r=$fontcolor['r']&amp;color_g=$fontcolor['g']&amp;color_b=$fontcolor['b']&amp;submit=Create+My+Sig%21/>
The variables are the same as i have on the creation page, which looks like:
Code: Select all
<?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'] <= '47')
{
    $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($size, 0, $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, $size, 0, $hpadding,$vpadding, $textcolor, $font, $name);
}else{
imagettftext($im, $size, $angle, $x, $y, $textcolor, $font, $name);
}
imagegif($im);
imagedestroy($im);
?>
and this is the important part of the form that sends them:
Code: Select all
<form method="get" action=http://gamesigs.co.uk/sig_created.php name="form" onsubmit="return checkit(this);">
When i change this form to go to the psge i have with the img src link on it it come up with a broken image. Where am i going wrong?
Reply With Quote
  #7 (permalink)  
Old Jan 4th, 2007, 16:02
New Member
Join Date: Jan 2007
Location: england
Age: 19
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Should be simple problems but im a complete newbie

Quote:
Originally Posted by DanDoughty View Post


Thats very clever - you ought to make it so u can have a tagline as well. Like id put - DanDoughty. Super Moderator!
thanks, thats a good idea i'm going to go attempt it now.
Reply With Quote
  #8 (permalink)  
Old Jan 6th, 2007, 19:57
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Should be simple problems but im a complete newbie

For starters, you want to put the entire img src path in quotes.

<img src="creation.php?color=$textcolor& . . . ">
Reply With Quote
  #9 (permalink)  
Old Jan 8th, 2007, 09:47
Daniel's Avatar
Elite Veteran
Join Date: Sep 2006
Location: The Kingdom of Rabbits
Age: 21
Posts: 2,051
Blog Entries: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Daniel
Re: Should be simple problems but im a complete newbie

Quote:
Originally Posted by digi duck View Post
thanks, thats a good idea i'm going to go attempt it now.
let us know when you've done it
Last Blog Entry: Assassin's Creed (Nov 22nd, 2007)
Reply With Quote
Reply

Tags
error, gamesigs, header, php, sigs

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie with problems with Ap div aligment megb6806 Starting Out 4 Nov 17th, 2007 08:58
newbie simple create database to record web page input jfb130 Databases 3 Aug 28th, 2005 16:37
complete newbie jonrice Web Page Design 6 Apr 25th, 2005 15:58
NEWBIE with a simple question! adventuredude Web Page Design 1 Jan 23rd, 2004 07:43


All times are GMT. The time now is 01:52.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43