php - Catch blank (including all-whitespace) form submissions -


If there is a problem on my site that users can post empty messages, if they use the location. ($ _ POST ['headline']) is empty ($ _ POST [* * *] 'text'])} empty ($ _ POST ['forum_id']) {/ P>

Header ("refresh: 2; url = / ad-thread"); Die ('you have to fill every field.'); } // no errors? Save Other {$ headline = mysql_real_escape_string ($ _ POST ['title']); $ Text = mysql_real_escape_string ($ _ POST ['text']); Include "Threads (title, text, date, forum_id, user_id)" in '$ headline', '$ text', NOW (), '$ _POST [forum_id]', '$ user [id]') ; Header ("Location: / thread /". Mysql_insert_id (). ""); }}

How can I fix this?

trim () text input you can do this easily: < / P> // Find input wires and trim space callback = array ('filter' = & gt; FILTER_CALLback, 'options' => 'trim'); $ Fields = filter_input_array (INPUT_POST, array ('title' = & gt; $ callback, 'text' = & gt; $ callback, 'forum_id' => $ callback,)); // count (array_filter ($ fields)) = {(some fields)) {// something was unstable}

/ html>

Comments