Olvidemos el primer ejemplo que di ya que era para hacerme una idea básica. Lo que realmente necesito conseguir es que quien entre en la web donde quiero insertar ese formulario pueda meter una serie de palabras que luego se estructuren en la base de datos.
Acabo de modificar el código pero mete todo en el mismo registro
Yo introduzco 3 paises separados por comas y me crea un nuevo registro con los 3 paises juntos no me los separa
Código PHP:
<?php require_once('../almacen/Connections/proba.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 ($tags = isset($_POST["tags"]) ? $_POST["tags"] : false); {
$tags = explode(",", $tags);
$insertSQL = "insert into pais (tags) values \n";
$contador = 0;
foreach($tags as $item){
if($contador) $sql .= ", ";
$contador++;
$insertSQL .= "\n('$item')";
}
mysql_select_db($database_proba, $proba);
$Result1 = mysql_query($insertSQL, $proba) or die(mysql_error());
$insertGoTo = "insertar.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
</form>
<form method="post" name="form2" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Pais:</td>
<td><input type="text" name="tags" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Insertar registro"></td>
</tr>
</table>
<input type="hidden" name="id" value="">
<input type="hidden" name="MM_insert" value="form2">
</form>
<p> </p>
</body>
</html>
Estoy haciendo algo mal y no se el que, gracias por la ayuda y paciencia, soy algo novato en esto