thebigchief Posted November 2, 2010 Share Posted November 2, 2010 After a few hours of serching the net for a perfect sollution I have decided to give up completely and ask for some help. if (isset($_POST['new'])) { $query = "INSERT INTO tickets SET "; if ( isset($_POST['hdtn']) ) { $query .= "hdtn='".$_POST['hdtn']."',"; } Can anyone tell me how to set this field as mandatory? Quote Link to comment Share on other sites More sharing options...
revraz Posted November 2, 2010 Share Posted November 2, 2010 if (isset($_POST['new'])) { $query = "INSERT INTO tickets SET "; if ( isset($_POST['hdtn']) ) { if (empty($_POST['hdtn'])) { die ("Error: Enter HDTN"); } $query .= "hdtn='".$_POST['hdtn']."',"; } Quote Link to comment Share on other sites More sharing options...
Anti-Moronic Posted November 2, 2010 Share Posted November 2, 2010 First, don't use die() in the above example and NEVER simply enter unfiltered user data into a sql query. It should be if(isset($_POST['new'])){ $query = "INSERT INTO tickets SET "; if(empty($_POST['hdtn'])){ echo "Error: Enter HDTN"; return; } $query .= "hdtn='".mysql_real_escape_string($_POST['hdtn'])."',"; } Quote Link to comment Share on other sites More sharing options...
thebigchief Posted November 2, 2010 Author Share Posted November 2, 2010 Guys........... Thanks SO much, this solved hours of work for me Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.