digi duck Posted March 27, 2007 Share Posted March 27, 2007 Hi I want users to be able to create an image from either an image template on my site (labelled $im) or by entering in a url.I think i've worked it out, but my php is not very good so can you tell me where i'm going wrong with it please? I realised that the $im = imagecreatefromjpeg($im) doesn't have to point to a variable, it can also point to a url i.e $im = imagecreatefromjpeg(http://www.address.com/image.jpeg) YEY- This works, however when i try adding a tick box to the html form that the user checks when they want to specify an address i get the url coming up instead of the image. This is the code that i have put in the php file... if($link== 'y'){ $im = imagecreatefromjpeg($useraddress); }else{ $im = imagecreatefromjpeg($im); } The checkbox is called link and the textbox for the address is called useraddress. If you want to see for yourself what its doing go to www.gamesigs.co.uk/test.php Cheers and i hope to hear from you soon. Link to comment https://forums.phpfreaks.com/topic/44544-can-you-check-my-short-code-snippet-please/ Share on other sites More sharing options...
per1os Posted March 27, 2007 Share Posted March 27, 2007 if($_POST['link']== 'y'){ $im = imagecreatefromjpeg($useraddress); }else{ $im = imagecreatefromjpeg($im); } Try that, if not post more code man. It is tough to try and fix a problem with only bits and pieces of the whole puzzle. Link to comment https://forums.phpfreaks.com/topic/44544-can-you-check-my-short-code-snippet-please/#findComment-216357 Share on other sites More sharing options...
digi duck Posted March 27, 2007 Author Share Posted March 27, 2007 no sorry it didnt work, here is the full code: for the html form: <form method="get" action="http://gamesigs.co.uk/testcreation.php" name="form" onsubmit="return checkit(this);"> <input name="link" type="checkbox" id="link" value="y" checked /> check to use address <input type="text" name="useraddress" id="useraddress" value="" style="width:117px;" /> for the php creation file: <?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'; } if($_POST['link']== 'y'){ $im = imagecreatefromjpeg($useraddress); }else{ $im = imagecreatefromjpeg($im); } //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); ?> MOD EDIT: digi_duck, use <?php ... ?> tags Link to comment https://forums.phpfreaks.com/topic/44544-can-you-check-my-short-code-snippet-please/#findComment-216366 Share on other sites More sharing options...
per1os Posted March 27, 2007 Share Posted March 27, 2007 my bad missed the $_GET part, try this: if($_GET['link']== 'y'){ $im = imagecreatefromjpeg($useraddress); }else{ $im = imagecreatefromjpeg($im); } If that does not work try printing out $_GET['link'] and see what value is displayed, it may display something you are not expected. Link to comment https://forums.phpfreaks.com/topic/44544-can-you-check-my-short-code-snippet-please/#findComment-216369 Share on other sites More sharing options...
digi duck Posted March 27, 2007 Author Share Posted March 27, 2007 no that new code didnt work ??? Any other ideas? p.s how do i print out the $_GET['link'] ??? i am a novice at best Link to comment https://forums.phpfreaks.com/topic/44544-can-you-check-my-short-code-snippet-please/#findComment-216434 Share on other sites More sharing options...
per1os Posted March 27, 2007 Share Posted March 27, 2007 print $_GET['link']; Chances are the value is not 'y' it is probably 'checked' or something similiar this would probably work: if(isset($_GET['link'])){ $im = imagecreatefromjpeg($useraddress); }else{ $im = imagecreatefromjpeg($im); } Link to comment https://forums.phpfreaks.com/topic/44544-can-you-check-my-short-code-snippet-please/#findComment-216460 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.