Zaktualizuj 'index.php'

This commit is contained in:
Krystian Rzepa 2018-12-28 19:12:00 +00:00
parent fa0e4f0079
commit 85eb827840

View File

@ -2,13 +2,33 @@
session_start();
$db_servername = 'localhost';
$db_login = '';
$db_password = '';
$db_name = '';
$db_login_tasks = '';
$db_password_tasks = '';
$db_name_tasks = '';
mysql_connect("$db_servername", "$db_login", "$db_password");
mysql_select_db("$db_name");
$db = mysqli_connect("$db_servername", "$db_login_tasks", "$db_password_tasks", "$db_name_tasks");
if (isset($_POST["submit"]) && $_SESSION['zalogowany'] = true) {
$task = $_POST["task"];
$login = $_SESSION['login'];
mysqli_query($db, "INSERT INTO `tasks_'$login'` (tasks) VALUES ('$task')");
header('location: index.php');
}
?>
<link rel="stylesheet" type="text/css" href="style.css">
<?php
function filter($variable)
{
if(get_magic_quotes_gpc())
@ -37,6 +57,43 @@ if (isset($_POST['loguj']))
if ($_SESSION['zalogowany']==true)
{
echo "Zalogowano jako <b>".$_SESSION['login']."</b>"; echo '<a href="?wyloguj=1"> [Wyloguj]</a>';
?>
<form method="POST" action="index.php">
<input type="text" name="task" class="task_input">
<input type="submit" value="Dodaj zadanie" name="submit">
</form>
<?php
$login = $_SESSION['login'];
$zapytanie = "SELECT * FROM `tasks_$login` ";
$tasks = mysqli_query($db, $zapytanie);
?>
<table>
<thead>
<tr>
<td>Numer</td>
<td>Zadanie</td>
<td>Akcja</td>
</tr>
</thead>
<tbody>
<?php while ($row = mysqli_fetch_array($tasks)) { ?>
<tr>
<td><?php echo $row['ID']; ?></td>
<td class="task"><?php echo $row['task']; ?></td>
<td class="delete">
<a href=#>USUN</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php
}
if ($_SESSION['zalogowany']==false): ?>