summaryrefslogtreecommitdiff
path: root/lib/list/new.php
blob: 9a9c801140cc5ac7422e11ddb78171ba08cddb09 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php

require("lib/markdown.php");

$list_name = "";
$list_comment = "";
if (isset($_POST["name"]) && isset($_POST['comment'])) {
	$list_name = esca($_POST['name']);
	$list_comment = esca($_POST['comment']);
	$list_comment_html = Markdown($list_comment);
	if ($list_name == "") {
		$error = "You must enter a name for your list.";
	} else if (mysql_fetch_assoc(sql("SELECT id FROM lists WHERE owner = " . $user['id'] . " AND name = '" . escs($list_name) . "'"))) {
		$error = "You already have a list with that title.";
	} else if ($list_comment == "") {
		$error = "Please enter a comment on your list.";
	} else {
		sql("INSERT INTO lists(owner, name, comment_md, comment_html) ".
			"VALUES(" . $user['id'] . ", '" . escs($list_name) . "', '" . escs($list_comment) . "', '" . escs($list_comment_html) . "')");
		header("Location: view-list-" . mysql_insert_id());
		die();
	}
}

$title = "Create list";
$fields = array(
	array("label" => "Name : ", "name" => "name", "value" => $list_name),
	array("label" => "Comment : ", "name" => "comment", "type" => "textarea", "value" => $list_comment),
	);
$validate = "Create list";

require("tpl/list/new.php");