Ir para conteúdo

Arquivado

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

PauloRJ

Incluir dados na tabela por checkbox

Recommended Posts

http://forum.imasters.com.br/public/style_emoticons/default/ermm.gif Ae pessoal tá dificil!

 

Estou tenando fazer uma pagina de cadastro onde o osuario selecione suas musicas preferidas.

 

Onde os campos selecionados sejam inlcuidos na tabela na coluna musica.

 

Mas da erro no cadastro, so nao tem erro se todos os campos forem selecionados.

 

Alguem sabe como me ajudar?

 

Funk

Axe

Forro

Mpb

Trance

hiphop

Compartilhar este post


Link para o post
Compartilhar em outros sites

Lá vai o codigo.

 

<?php require_once('Connections/con_exibidos.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 = $_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 musica (funk, axe, forro, mpb, trance, sertanejo, hiphop) VALUES (%s, %s, %s, %s, %s, %s, %s)",

GetSQLValueString($_POST['funk'], "text"),

GetSQLValueString($_POST['axe'], "text"),

GetSQLValueString($_POST['forro'], "text"),

GetSQLValueString($_POST['mpb'], "text"),

GetSQLValueString($_POST['trance'], "text"),

GetSQLValueString($_POST['sertanejo'], "text"),

GetSQLValueString($_POST['hiphop'], "text"));

 

mysql_select_db($database_con_exibidos, $con_exibidos);

$Result1 = mysql_query($insertSQL, $con_exibidos) or die(mysql_error());

 

$insertGoTo = "lado.htm";

if (isset($_SERVER['QUERY_STRING'])) {

$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";

$insertGoTo .= $_SERVER['QUERY_STRING'];

}

header(sprintf("Location: %s", $insertGoTo));

}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

 

<body>

<form method="post" name="form1" action="<?php echo $editFormAction; ?>">

<table align="center">

<tr valign="baseline">

<td nowrap align="right">Funk:</td>

<td><input type="checkbox" name="funk" value="funk" size="32"></td>

</tr>

<tr valign="baseline">

<td nowrap align="right">Axe:</td>

<td><input type="checkbox" name="axe" value="axe" size="32"></td>

</tr>

<tr valign="baseline">

<td nowrap align="right">Forro:</td>

<td><input type="checkbox" name="forro" value="forró" size="32"></td>

</tr>

<tr valign="baseline">

<td nowrap align="right">Mpb:</td>

<td><input type="checkbox" name="mpb" value="mpb" size="32"></td>

</tr>

<tr valign="baseline">

<td nowrap align="right">Trance:</td>

<td><input type="checkbox" name="trance" value="trance" size="32"></td>

</tr>

<tr valign="baseline">

<td nowrap align="right">Sertanejo:</td>

<td><input type="checkbox" name="sertanejo" value="sertanejo" size="32"></td>

</tr>

<tr valign="baseline">

<td nowrap align="right">Hiphop:</td>

<td><input type="checkbox" name="hiphop" value="hiphop" size="32"></td>

</tr>

<tr valign="baseline">

<td nowrap align="right"> </td>

<td><input type="submit" value="Insert record"></td>

</tr>

</table>

<input type="hidden" name="MM_insert" value="form1">

</form>

 

<p> </p>

</body>

</html>

 

 

 

Espero q tenha entendido.

Valeu a Força!!!

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.