MyBB Community Forums

Full Version: Post Data from Form to Script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hey there. This isn't really MyBB related but I really need some help. I found this script that you can see below:
<?php
// Your Twitter username.
$twittername = "";


$xml = simplexml_load_file("http://twitter.com/statuses/user_timeline/".$twittername.".rss?count=1");
$updated = strtotime($xml->channel->item->pubDate);
$updated = date("M d, Y, h:i a", $updated);
$tweet = str_replace($twittername.": ", "", $xml->channel->item->description);
$t = wordwrap($tweet, 60, "|");
$output = explode("|", $t);

// create image
$im = imagecreatefromjpeg("twitter.jpg");

// The color of your twitter username.
$username_color = imagecolorallocate($im, 180, 0, 0);

// The color of the date.
$date_color = imagecolorallocate($im, 120, 120, 120);

// The color of your tweet.
$tweet_color = imagecolorallocate($im, 0, 0, 0);

// Font to use.
$font = "arial.ttf";

imagettftext($im, 10, 0, 90, 18, $username_color, $font, $twittername);
imagettftext($im, 10, 0, 250, 18, $date_color, $font, $updated);
$y = 25; // Y position of the first line of your tweet.
foreach($output as $text) {
	$y = $y + 15;
	imagettftext($im, 10, 0, 10, $y, $tweet_color, $font, $text);
}

// output the image
header("Content-type: image/png");
imagepng($im);
?>

What I want to do is make it so when someone posts their Twitter Username in a Form, it will take that data and put it in the $twittername form. Can someone please help me with this?Huh

I would also like it to change the file name to the person's name so that it doesn't get confused when there are multiple people using it.
$twittername = $_POST['whatevervariableyouusedfortheusername'];

??

for naming the file just use:

imagepng($im, '{$twittername}.png');

should work, i think.
Alright, let me try it out. Thanks for the quick responce, Ill thank you when I have it up.
^that's assuming you already have the HTML form to submit the data set up, right?
I need some help now, when I tried testing it, well, see for your self.

http://www.dynamicsignatures.co.cc/twitter.html
Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/chasingu/public_html/dynamicsignatures.co.cc/twitter.php on line 31

Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/chasingu/public_html/dynamicsignatures.co.cc/twitter.php on line 32

Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/chasingu/public_html/dynamicsignatures.co.cc/twitter.php on line 36

Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/chasingu/public_html/dynamicsignatures.co.cc/twitter.php on line 36

Warning: Cannot modify header information - headers already sent by (output started at /home/chasingu/public_html/dynamicsignatures.co.cc/twitter.php:31) in /home/chasingu/public_html/dynamicsignatures.co.cc/twitter.php on line 40
$font = "arial.ttf";
make sure arial.ttf is uploaded to the same directory.
It is, its in the same directory as the twitter script is.

It is in the home directory if that matters.
Well it says can't find/open.

There could be a possibility that your PHP GD doesn't support font?
I am pretty sure that it does, because another one of my signature scripts does it fine.
Hm it could be two more things:
1.The file name is case-sensitive
2.PHP might not have permissions to open the font, in which you'd have to chmod it.
Pages: 1 2