Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá pessoal!
Estou tendo problemas com um formulário em PHP dentro do Dreamweaver MX. Criei uma tabela no banco de dados MySQL pelo PhpMyAdmin, fiz a conexão e utilizei o comportamento de servidor para inserir registro dentro do DW porque não conheço PHP. Até aí, tudo certo, mas quando vou testar o aplicativo no meu localhost acontece o problema. Preencho o formulário e quando clico no botão para enviar, a página simplesmente recarrega, como se tivesse dado um F5, e não envia os dados para o BD. E ao meu ver, está tudo certo, inclusive a indicação da página que deveria ser carregada após o envio do formulário. Bem, o código que o DW está gerando é este aí de baixo. Se alguém puder ajudar eu ficaria muito grato, pois este problema persiste há semana.
<?php require_once('Connections/connPMMC.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO noticias (titulo, texto) VALUES (%s, %s)",
GetSQLValueString($HTTP_POST_VARS['titulo'], "text"),
GetSQLValueString($HTTP_POST_VARS['texto'], "text"));
mysql_select_db($database_connPMMC, $connPMMC);
$Result1 = mysql_query($insertSQL, $connPMMC) or die(mysql_error());
$insertGoTo = "recebe.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}Carregando comentários...