Jump to content

Making a field Mandatory


thebigchief

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/217544-making-a-field-mandatory/
Share on other sites

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'])."',";

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.