diff --git a/exam104/example.xml b/exam104/example.xml new file mode 100755 index 0000000..f548b5b --- /dev/null +++ b/exam104/example.xml @@ -0,0 +1,26 @@ + + + Alex + 21 + + A show + 12th December 2010 + + + Another show + 23th Novembar 2024 + + + + Nikola + 16 + + Better show + 25th Novembar 2007 + + + + Dale + 49 + + \ No newline at end of file diff --git a/exam104/index.php b/exam104/index.php new file mode 100644 index 0000000..63b6088 --- /dev/null +++ b/exam104/index.php @@ -0,0 +1,13 @@ +producer as $producer){ + echo $producer->name.' ('. $producer->age .')'. "
"; + foreach($producer->show as $show){ + echo $show->showname. ' ('.$show->showdate.')' .'
'; + } +} + + +?> \ No newline at end of file diff --git a/exam110/connect.inc.php b/exam110/connect.inc.php new file mode 100644 index 0000000..74d1106 --- /dev/null +++ b/exam110/connect.inc.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/exam115/index.php b/exam115/index.php new file mode 100644 index 0000000..f31697b --- /dev/null +++ b/exam115/index.php @@ -0,0 +1,40 @@ + + +
+ Choose a food type: +

+ +
+ +'; + } + } + } else { + echo 'Query failed.'; + } + } else { + echo 'Must be u or h'; + } +} diff --git a/exam123/index.php b/exam123/index.php new file mode 100644 index 0000000..96d7407 --- /dev/null +++ b/exam123/index.php @@ -0,0 +1,49 @@ += 1) { + return true; + } +} + +function ip_add($ip) +{ + global $con; + $query = "INSERT INTO `hits_ip` VALUES ('$ip')"; + $query_run = mysqli_query($con, $query); +} + +function update_count() +{ + global $con; + $query = "SELECT `count` FROM `hits_count` "; + if ($query_run = mysqli_query($con, $query)) { + $row = mysqli_fetch_assoc($query_run); + $count = $row['count']; + $count_inc = $count + 1; + + $query_update = "UPDATE `hits_count` SET `count` = '$count_inc'"; + $query_update_run = mysqli_query($con, $query_update); + + } +} + +if (!ip_exists($user_ip)) { + update_count(); + ip_add(($user_ip)); +} + +?> + +

My page

\ No newline at end of file diff --git a/exam123/srcphp5.php b/exam123/srcphp5.php new file mode 100644 index 0000000..125a833 --- /dev/null +++ b/exam123/srcphp5.php @@ -0,0 +1,31 @@ + 0) { + // $count = mysql_result($query_run, 0,'count'); + // $count_inc = $count + 1; + +// $query_update = "UPDATE `hits_count` SET `count` = '$count_inc'"; +// if ($query_update_run = mysqli_query($con, $query_update)) { + echo 'OK'; + } + } + } +//} + +update_count(); diff --git a/exam130/index.php b/exam130/index.php new file mode 100644 index 0000000..18ed90a --- /dev/null +++ b/exam130/index.php @@ -0,0 +1,32 @@ += 4) { + + $query = "SELECT `name` FROM `names` WHERE `name` LIKE '%" . mysqli_real_escape_string($con, $search_name) . "%'"; + $query_run = mysqli_query($con, $query); + + $query_num_rows = mysqli_num_rows($query_run); + if ($query_num_rows >= 1) { + echo $query_num_rows . ' results found:
'; + while ($query_row = mysqli_fetch_assoc($query_run)) { + echo $query_row['name'] . '
'; + } + } + } else{ + echo 'Your keyword must be 5 caracters or more'; + } + } +} + +?> + +
+ Name: + +
\ No newline at end of file diff --git a/exam135/core.inc.php b/exam135/core.inc.php new file mode 100644 index 0000000..4ccd2b1 --- /dev/null +++ b/exam135/core.inc.php @@ -0,0 +1,26 @@ + diff --git a/exam135/index.php b/exam135/index.php new file mode 100644 index 0000000..c656b03 --- /dev/null +++ b/exam135/index.php @@ -0,0 +1,13 @@ +Log out
'; +} else { + include 'loginform.inc.php'; +} +?> \ No newline at end of file diff --git a/exam135/loginform.inc.php b/exam135/loginform.inc.php new file mode 100644 index 0000000..6a7645b --- /dev/null +++ b/exam135/loginform.inc.php @@ -0,0 +1,37 @@ + + +
+ Username: Password: + +
\ No newline at end of file diff --git a/exam135/logout.php b/exam135/logout.php new file mode 100644 index 0000000..affd1c2 --- /dev/null +++ b/exam135/logout.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/exam135/register.php b/exam135/register.php new file mode 100644 index 0000000..42b38d3 --- /dev/null +++ b/exam135/register.php @@ -0,0 +1,69 @@ + 30 || strlen($firstname) > 40 || strlen($surname) > 40){ + echo 'Please ahear to maxlength of fields'; + }else{ + if ($password != $password_again) { + echo 'Passwords do not match'; + } else { + $query = "SELECT `username` FROM `users` WHERE `username` ='$username'"; + $query_run = mysqli_query($con, $query); + if (mysqli_num_rows($query_run) == 1) { + echo 'The username ' . $username . 'already exists'; + } else { + $query = "INSERT INTO `users` VALUES(NULL ,'" . mysqli_real_escape_string($con, $username) . + "','" . mysqli_real_escape_string($con, $password_hash) . "','" . mysqli_real_escape_string($con, $firstname) . + "','" . mysqli_real_escape_string($con, $surname) . "')"; + if($query_run = mysqli_query($con,$query)){ + header('Location: register_success.php'); + } else { + echo 'We could not register you!'; + } + + } + } + } + } else { + echo 'All fields are required'; + } + } +?> + +
+ Username:


+ Password:


+ Password again:


+ Firstname:


+ Surname:


+ +
+ + \ No newline at end of file diff --git a/exam135/register_success.php b/exam135/register_success.php new file mode 100644 index 0000000..ed5a462 --- /dev/null +++ b/exam135/register_success.php @@ -0,0 +1 @@ +

You are registered !

\ No newline at end of file