Skip to content

Instantly share code, notes, and snippets.

@SunboX
Created June 5, 2012 09:44
Show Gist options
  • Select an option

  • Save SunboX/2874014 to your computer and use it in GitHub Desktop.

Select an option

Save SunboX/2874014 to your computer and use it in GitHub Desktop.
<?php
$bildUrl = '';
if(isset($_POST['submit_button'])){ // Formular wurde verschickt
// Texte
$ort = isset($_POST['ort']) ? $_POST['Ort'] : '';
$landkreis = isset($_POST['landkreis']) ? $_POST['landkreis'] : '';
$text = $ort . "\n" . $landkreis;
// Bild erzeugen
$img = imagecreate(200, 70);
$bgColor = imagecolorallocate($img, 255, 255, 255);
$textColor = imagecolorallocate($bild, 0, 0, 0);
imagefill($img, 0, 0, $bgColor);
imagestring($img, 2, 0, 0, $text, $textColor);
// Das Bild als JPG speichern
$bildUrl = 'schild_' . md5(microtime() . rand(0, 9999)) . '.jpg';
imagejpeg($img, $bildUrl);
}
?>
<!doctype html>
<head>
<meta charset="utf-8">
</head>
<body>
<form method="post" action="<?php echo basename($_SERVER['PHP_SELF']); ?>>
<label for="ort">Ort:</label> <input type="text" name="ort"/><br/>
<label for="landkreis">Landkreis:</label> <input type="text" name="landkreis"/><br/>
<input type="submit" name="submit_button" value="Bildchen Anzeigen"/>
</form>
<?php if($bildUrl !== ''): ?>
<br/><br/>
<img src="<?php echo $bildUrl; ?>" width="200" height="70"/>
<?php endif; ?>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment