Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

John Wesley

Formulario de cadastro com data automatica

Recommended Posts

Opa, e o seguinte estou fazendo um sistema de solicitações no Dreamweaver, fiz o cadastro de solicitação(já está funcionando), so q e o seguinte; quando a solicitação é concluida e pessoa aperta um botão que grava o formulario en outra tabela eexclui das solicitações pendentes, só que eu queria que quando ela apertase esse botão salvac a data e a hora automaticamente e na minha base de dados, assim eu poderia consultar que dia que foi feita a determinada solicitação.

 

Espero ter sido claro, vou colocar abaixo o formulario:

<?php require_once('Connections/conect_solicitacao.php'); ?>
<?php require_once('Connections/conect_solicitacao.php'); ?>
<?php require_once('Connections/conect_solicitacao.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $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"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO solicitacao_concluido (C_ID, C_Cliente, C_Data, C_Funcionario, C_Solicitacao, C_Datafinal) VALUES (%s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['Soli_ID'], "int"),
                       GetSQLValueString($_POST['Soli_Cliente'], "text"),
                       GetSQLValueString($_POST['Soli_Data'], "text"),
                       GetSQLValueString($_POST['Soli_Funcionario'], "text"),
                       GetSQLValueString($_POST['Soli_Descricao'], "text"),
                       GetSQLValueString($_POST['Soli_Datafinal'], "text"));

  mysql_select_db($database_conect_solicitacao, $conect_solicitacao);
  $Result1 = mysql_query($insertSQL, $conect_solicitacao) or die(mysql_error());

  $insertGoTo = "concluida-sucesso.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

$colname_Recordset1 = "-1";
if (isset($_GET['Soli_ID'])) {
  $colname_Recordset1 = $_GET['Soli_ID'];
}
mysql_select_db($database_conect_solicitacao, $conect_solicitacao);
$query_Recordset1 = sprintf("SELECT * FROM solicitacao WHERE Soli_ID = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $conect_solicitacao) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!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=iso-8859-1">
<title>:: Sistema de Solicitação</title>
<script type="text/javascript">
<!--
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
////////////                                   //-->

function mascaraData(campoData){
              var data = campoData.value;
              if (data.length == 2){
                  data = data + '/';
                  document.forms[0].data.value = data;
      return true;              
              }
              if (data.length == 5){
                  data = data + '/';
                  document.forms[0].data.value = data;
                  return true;
              }

</script>

<style type="text/css">
<!--
obrigatorio {
	font-size: 14px;
}
.obrigatorio {
	font-family: Tahoma, Geneva, sans-serif;
	font-size: 11px;
	color: #F00;
	font-weight: bold;
}
-->
</style>
</head>

<body>
<form action="<?php echo $editFormAction; ?>" method="POST" name="form1" id="form1">
  <table align="center">
    <tr valign="baseline">
      <td width="136" align="right" nowrap="nowrap"> </td>
      <td colspan="2"><input name="Soli_ID" type="hidden" id="Soli_ID" value="<?php echo $row_Recordset1['Soli_ID']; ?>" /></td>
    </tr>
    <tr valign="baseline">
      <td width="136" align="right" nowrap="nowrap">Nome da empresa:</td>
      <td colspan="2"><input name="Soli_Cliente" type="text" value="<?php echo $row_Recordset1['Soli_Cliente']; ?>" size="40" readonly="readonly" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Data da solicitação:</td>
      <td colspan="2"><input name="Soli_Data" type="text" value="<?php echo $row_Recordset1['Soli_Data']; ?>" size="10" maxlength="10" readonly="readonly" onkeypress="mascara(this, '### ### ###')"/></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Nome do funcionário:</td>
      <td colspan="2"><input name="Soli_Funcionario" type="text" value="<?php echo $row_Recordset1['Soli_Funcionario']; ?>" size="40" readonly="readonly" /></td>
    </tr>
    <tr valign="baseline">
      <td align="right" valign="top" nowrap="nowrap">Solicitação:</td>
      <td colspan="2"><textarea name="Soli_Descricao" cols="50" rows="10" readonly="readonly"><?php echo $row_Recordset1['Soli_Descricao']; ?></textarea></td>
    </tr>
    <tr valign="baseline">
      <td align="right" valign="top" nowrap="nowrap">Data da finalização:</td>
      <td><input name="data" type="text" id="data" OnKeyUp="mascaraData(this);" value="" size="10" maxlength="10"/></td>
      <td><span class="obrigatorio">* Este campo é obrigatório</span></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right"> </td>
      <td width="89"><input type="submit" value="Concluir Solicitação" /></td>
      <td width="433"><label>
        <input name="button" type="button" id="button" onclick="MM_goToURL('parent','listar.php');return document.MM_returnValue" value="Voltar" />
      </label></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($Recordset1);

mysql_free_result($Recordset1);

mysql_free_result($Recordset1);

mysql_free_result($concluir);

mysql_free_result($concluir);
?>

Desde ja agradeço

Compartilhar este post


Link para o post
Compartilhar em outros sites

Compartilhar este post


Link para o post
Compartilhar em outros sites

Consegui resolver isso assim:

<script type="text/javascript">

function doTime(){

d = new Date;

m_seconds = d.getMilliseconds();

seconds = d.getSeconds();

hours = d.getHours();

minutes= d.getMinutes();

dia = d.getDate();

month = d.getMonth() -1 +2;

year = d.getUTCFullYear();

 

x=document.getElementById('data'); //onde a data vai aparecer

 

x.innerHTML = 'Hoje é '+dia+'/'+month+'/'+year+' --- São '+hours+':'+minutes+':'+seconds+'';

 

}

function cTime(){

setInterval('doTime()',1);

}

</script>

<body onload="cTime();">

<font id="data"></font>

</body>

MAis agora como que envio para a base de dados essa data e hora?

E Mysql

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.