Add exams from exam156 to exam199

This commit is contained in:
2024-05-16 10:51:54 +02:00
parent 19bf1b8ac8
commit 959a167e9d
29 changed files with 635 additions and 0 deletions

37
exam156/generate.php Normal file
View File

@@ -0,0 +1,37 @@
<?php
header('Content-type: image/jpeg');
$mysql_host = 'localhost';
$mysql_user = 'example_user';
$mysql_pass = 'Kolosnjaj4321!';
$mysql_db = 'example_database';
$con = mysqli_connect($mysql_host, $mysql_user, $mysql_pass);
mysqli_select_db($con, $mysql_db);
if (isset($_GET['id'])) {
$id = $_GET['id'];
$query = mysqli_query($con, "SELECT `email` FROM `users` WHERE `id` ='" . mysqli_real_escape_string($con, $id) . "'");
if (mysqli_num_rows($query) >= 1) {
$query_result = mysqli_fetch_assoc($query);
$email = $query_result['email'];
} else {
$email = 'ID not found';
}
} else {
$email = 'No id specified.';
}
$email_length = strlen($email);
$font_size = 4;
$image_height = imagefontheight($font_size);
$image_width = imagefontwidth($font_size) * $email_length;
$image = imagecreate($image_width, $image_height); // Stvaranje prazne slike
imagecolorallocate($image, 255, 255, 255); // boja pozadine podesena na belo
$font_color = imagecolorallocate($image, 0, 0, 0); // boja fonta podesena na belo
imagestring($image, $font_size, 0, 0, $email, $font_color);
imagejpeg($image);

4
exam156/index.php Normal file
View File

@@ -0,0 +1,4 @@
Name:<br>
Alex <br><br>
Email:<br>
<img src="generate.php?id=2">