Jump to content


Turetto

Member Since 11/01/2008
Offline Last Active 18/01/2008, 10:16
-----

Topics I've Started

Campo Vazio Não Enviar

11/01/2008, 11:09

Bom dia pessoal, seguinte tenho um fomulario de cadastro chamado cad_lic.php, e nele existe alguns campo que não podem ficar em branco no banco, so que quando mando enviar ele cadastra o campo em branco e isso nao pode acontecer como faço pra resolver esse problema.

O meu codigo fonte é esse:
<?php require_once('Connections/cigas.php'); ?><?phpif (!isset($_SESSION)) {  session_start();}$MM_authorizedUsers = "adm";$MM_donotCheckaccess = "false";//recebe do formulario// *** Restrict Access To Page: Grant or deny access to this pagefunction isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {   // For security, start by assuming the visitor is NOT authorized.   $isValid = False;   // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.   // Therefore, we know that a user is NOT logged in if that Session variable is blank.   if (!empty($UserName)) {     // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.     // Parse the strings into arrays.     $arrUsers = Explode(",", $strUsers);     $arrGroups = Explode(",", $strGroups);     if (in_array($UserName, $arrUsers)) {       $isValid = true;     }     // Or, you may restrict access to only certain users based on their username.     if (in_array($UserGroup, $arrGroups)) {       $isValid = true;     }     if (($strUsers == "") && false) {       $isValid = true;     }   }   return $isValid; }$MM_restrictGoTo = "intranet.php";if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {     $MM_qsChar = "?";  $MM_referrer = $_SERVER['PHP_SELF'];  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)   $MM_referrer .= "?" . $QUERY_STRING;  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);  header("Location: ". $MM_restrictGoTo);   exit;}?><?phpif (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);  switch ($theType) {    case "text":      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";      break;        case "long":    case "int":      $theValue = ($theValue != "") ? intval($theValue) : "NULL";      break;    case "double":      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";      break;    case "date":      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";      break;    case "defined":      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;      break;  }  return $theValue;}}$editFormAction = $_SERVER['PHP_SELF'];if (isset($_SERVER['QUERY_STRING'])) {  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);}if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) /*&& ($_POST['num_lic'] != ''))*/{  $insertSQL = sprintf("INSERT INTO licitacoes (tit_lic, dat_lic, num_lic, hor_lic, obj_lic, res_lic, tel_lic, ema_lic, sta_lic, dat_pub_lic, dat_abe_lic, val_est, hor_abe_lic) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",                       GetSQLValueString($_POST['tit_lic'], "text"),                       GetSQLValueString($_POST['Dat_lic'], "date"),                       GetSQLValueString($_POST['num_lic'], "text"),                       GetSQLValueString($_POST['hor_lic'], "date"),                       GetSQLValueString($_POST['obj_lic'], "text"),                       GetSQLValueString($_POST['res_lic'], "text"),                       GetSQLValueString($_POST['tel_lic'], "text"),                       GetSQLValueString($_POST['ema_lic'], "text"),                       GetSQLValueString($_POST['sta_lic'], "text"),                       GetSQLValueString($_POST['dat_pub_lic'], "date"),                       GetSQLValueString($_POST['dat_abe_lic'], "date"),                       GetSQLValueString($_POST['val_est'], "text"),                       GetSQLValueString($_POST['hor_abe_lic'], "date"));  mysql_select_db($database_cigas, $cigas);  $Result1 = mysql_query($insertSQL, $cigas) or die(mysql_error());}if (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);  switch ($theType) {    case "text":      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";      break;        case "long":    case "int":      $theValue = ($theValue != "") ? intval($theValue) : "NULL";      break;    case "double":      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";      break;    case "date":      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";      break;    case "defined":      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;      break;	case 3:		echo "Verifique os campos em branco";	break;  }  return $theValue;}}// Data do formulario......$data = date("y-m-d");  $hora = date("H:i:s"); ?><script language="JavaScript">function isBlank(val){ 	 if(val==null){return true;}	   for(var i=0;i<val.length;i++) {		   if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}	   }	   return true;   }    function verificavazio(elemento){	if (isBlank(document.getElementById("num_lic").value))	{		alert("Preencha o campo Numero");		elemento.elements["num_lic"].focus();		return false;	}	else		return true;		}		</script><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Companhia de Gás do Amazonas - Cigás</title><style type="text/css"><!--a:link {	color: #000066;	text-decoration: none;}a:visited {	color: #000066;	text-decoration: none;}a:hover {	color: #000066;	text-decoration: underline;}a:active {	color: #000066;	text-decoration: none;}body,td,th {	color: #666666;}.style40 {color: #FFFFFF; font-weight: bold; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; }.style41 {color: #000000}body {	background-image: url();	background-color: #FFFFFF;}.style45 {	font-family: Arial, Helvetica, sans-serif;	color: #000066;	font-weight: bold;	font-size: 17px;}.style46 {	font-family: Verdana, Arial, Helvetica, sans-serif;	font-size: 11px;}.style47 {color: #000066}--></style><script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script><script type="text/JavaScript"><!--function MM_swapImgRestore() { //v3.0  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}function MM_preloadImages() { //v3.0  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}function MM_findObj(n, d) { //v4.01  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);  if(!x && d.getElementById) x=d.getElementById(n); return x;}function MM_swapImage() { //v3.0  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}//--></script><link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /></head><body onload="MM_preloadImages('imagens/Fig_Email2.gif')"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="missao">  <tr>    <td><div align="center">    <label></label>        <div align="left"><span class="style45">Cadastro de Licitação </span></div>    <div align="center"></div></td>  </tr></table><?php//inicio do form?><form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form" id="form">  <table width="100%" border="1" align="center" cellpadding="0" cellspacing="2" bordercolor="#FFFFFF" bgcolor="#FFFFFF">    <tr bordercolor="#000000" bgcolor="#DBDBDB">      <td width="25%" height="25" bgcolor="#DBDBDB"><div align="center" class="style40 style47">          <div align="left"> Titulo:</div>      </div></td>      <td height="25" colspan="3" bgcolor="#FFFFFF"><span id="sprytextfield1">        <input name="tit_lic" type="text" id="tit_lic" size="50" maxlength="50" />        <span class="textfieldRequiredMsg">Este campo é obrigatorio!</span></span><input name="Dat_lic" type="hidden" id="Dat_lic2" value="<?php echo $data; ?>" />      <input name="hor_lic" type="hidden" id="hor_lic2" value="<?php echo $hora; ?>" /></td>    </tr>    <tr bordercolor="#000000" bgcolor="#DBDBDB">      <td width="25%" height="11" bgcolor="#DBDBDB"><div align="center" class="style40 style47">          <div align="left"> Número:</div>      </div></td>      <td width="20%" height="11" bgcolor="#FFFFFF"><input name="num_lic" type="text" id="num_lic" size="20" maxlength="10" />      </td>      <td width="18%" bgcolor="#FFFFFF"><div align="center" class="style40 style47">        <div align="left"> &nbsp;Hora Abertura:</div>      </div></td>      <td width="37%" bgcolor="#FFFFFF"><input name="hor_abe_lic" type="text" id="hor_abe_lic" size="20" maxlength="8" /></td>    </tr>    <tr bordercolor="#000000" bgcolor="#DBDBDB">      <td width="25%" height="12" bgcolor="#DBDBDB"><div align="center" class="style40 style47">          <div align="left"> Data da Publicação:</div>      </div></td>      <td height="12" bgcolor="#FFFFFF"><input name="dat_pub_lic" type="text" id="dat_pub_lic" size="20" maxlength="10" /></td>      <td height="12" bgcolor="#FFFFFF"><div align="center" class="style40 style47">        <div align="left"> Data Abertura:</div>      </div></td>      <td height="12" bgcolor="#FFFFFF"><input name="dat_abe_lic" type="text" id="dat_abe_lic" size="20" maxlength="20" /></td>    </tr>    <tr bordercolor="#000000" bgcolor="#DBDBDB">      <td width="25%" height="25" bgcolor="#DBDBDB"><div align="center" class="style40 style47">          <div align="left"> Objeto:</div>      </div></td>      <td height="25" colspan="3" bgcolor="#FFFFFF"><label>        <textarea name="obj_lic" cols="50" rows="5" id="obj_lic"></textarea>      </label></td>    </tr>    <tr bordercolor="#000000" bgcolor="#DBDBDB">      <td height="25" bgcolor="#DBDBDB"><div align="center" class="style40 style47">          <div align="left"> Valor Estimado:</div>      </div></td>      <td height="25" colspan="3" bgcolor="#FFFFFF"><input name="val_est" type="text" id="val_est" size="50" maxlength="25" /></td>    </tr>    <tr bordercolor="#000000" bgcolor="#DBDBDB">      <td height="25" bgcolor="#DBDBDB"><div align="center" class="style40 style47">          <div align="left"> Responsável:</div>      </div></td>      <td height="25" colspan="3" bgcolor="#FFFFFF"><input name="res_lic" type="text" id="res_lic" size="50" maxlength="25" /></td>    </tr>    <tr bordercolor="#000000" bgcolor="#DBDBDB">      <td height="25" bgcolor="#DBDBDB"><div align="center" class="style40 style47">          <div align="left"> Telefone:</div>      </div></td>      <td height="25" colspan="3" bgcolor="#FFFFFF"><input name="tel_lic" type="text" id="tel_lic" size="50" maxlength="25" /></td>    </tr>    <tr bordercolor="#000000" bgcolor="#DBDBDB">      <td height="25" bgcolor="#DBDBDB"><div align="center" class="style40 style47">          <div align="left"> E-mail:</div>      </div></td>      <td height="25" colspan="3" bgcolor="#FFFFFF"><input name="ema_lic" type="text" id="ema_lic" size="50" maxlength="25" /></td>    </tr>    <tr bordercolor="#000000" bgcolor="#DBDBDB">      <td height="25" bgcolor="#DBDBDB"><div align="center" class="style40 style47">          <div align="left"> Status:</div>      </div></td>      <td height="25" colspan="3" bgcolor="#FFFFFF"><select name="sta_lic" id="sta_lic">          <option value="Inativo">Selecione um</option>          <option value="Novas">Novas</option>          <option value="Andamento">Andamento</option>          <option value="Encerradas">Encerradas</option>      </select></td>    </tr>  </table>    <input type="hidden" name="MM_insert" value="form1"><input type="hidden" name="MM_insert" value="form" onClick="verifica_campos();"/><input type="hidden" name="MM_insert" value="form" /></form><table width="100%" border="1" align="center" cellpadding="0" cellspacing="2" bordercolor="#FFFFFF" bgcolor="#FFFFFF">  <tr bordercolor="#000000" bgcolor="#DBDBDB">    <td width="50%" height="25" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><label></label></td>    <td width="20%" height="25" bordercolor="#FFFFFF" bgcolor="#FFFFFF">&nbsp;</td>    <td width="10%" bordercolor="#FFFFFF" bgcolor="#FFFFFF">&nbsp;</td>    <td width="10%" bordercolor="#000000" bgcolor="#FFFFFF">    <div align="center" class="style46"><a href="java script:document.form.submit()">Salvar</a></div>      <a href="cont_index.php"></a></td>    <td width="10%" bgcolor="#FFFFFF"><div align="center" class="style46"><a href="cont_lic.php">Voltar</a></div></td>  </tr></table><p>&nbsp;</p>
Sem mais, agradeço desde ja a todos...

-- Desenvolver é uma arte não uma pratica --

IPB Skin By Virteq