Skip to content
Browse files

Saving form_url when saving forms

  • Loading branch information...
1 parent 7b8861d commit 5b000e2c3e6d0930cc990033c1f47036d5e09fc0 Michal Migurski committed Feb 7, 2012
Showing with 11 additions and 2 deletions.
  1. +1 −0 site/doc/create.mysql
  2. +1 −1 site/lib/lib.forms.php
  3. +9 −1 site/www/add-form.php
View
1 site/doc/create.mysql
@@ -167,6 +167,7 @@ CREATE TABLE forms (
) ENGINE=InnoDB, CHARACTER SET utf8;
+ALTER TABLE forms ADD COLUMN form_url TEXT AFTER title;
ALTER TABLE forms ADD COLUMN failed INT UNSIGNED DEFAULT 0 AFTER parsed;
View
2 site/lib/lib.forms.php
@@ -145,7 +145,7 @@ function set_form(&$dbh, $form)
$update_clauses = array();
- foreach(array('http_method', 'action_url', 'title', 'user_id') as $field)
+ foreach(array('form_url', 'http_method', 'action_url', 'title', 'user_id') as $field)
if(!is_null($form[$field]))
if($form[$field] != $old_form[$field])
$update_clauses[] = sprintf('%s = %s', $field, $dbh->quoteSmart($form[$field]));
View
10 site/www/add-form.php
@@ -17,13 +17,21 @@
if($_POST['form_url'])
{
+ if(empty($_POST['form_url']))
+ {
+ header('HTTP/1.1 400');
+ die("Empty or missing form_url.\n");
+ }
+
$added_form = add_form($dbh, $user_id);
+ $added_form['form_url'] = $_POST['form_url'];
if(!empty($_POST['form_title']))
{
$added_form['title'] = $_POST['form_title'];
- set_form($dbh, $added_form);
}
+
+ set_form($dbh, $added_form);
$message = array('action' => 'import form',
'url' => $_POST['form_url'],

0 comments on commit 5b000e2

Please sign in to comment.
Something went wrong with that request. Please try again.