Hi , i am trying to make a to do list where i can add things i still need to do . i also want to remove items from the list when they are done , this is what i made now but it still misses a lot , my array keeps getting emptied when i add something.
im still a beginner in php. This is the file without the css included , i don't think it's relevant to this question to include it.
<?php
session_start();
var_dump( $_POST);
$items = array();
if( ! empty($_POST['item'])) {
$items[] = $_POST['item'];
}
//<?php for ($i=0; $i < count($items) ; $i++) :
//<?php endfor;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>To do : periodeopdracht</title>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<div class="list">
<h1 class="header">To do </h1>
<form action="index.php" class="item-add" method="post">
<ul class="items">
<?php foreach($items as $item):
echo '<li>' . $item . '<li>' ;
endforeach; ?>
</ul>
<input type="text" name="item" placeholder="Typ uw nieuw item hier" class="input" autocomplete="off" required>
<input type="submit" value="toevoegen" class="submit" name="submit">
</form>
</div>
</body>
</html>