update-butxaca.php
author viric@vicerveza
Thu, 18 May 2006 23:47:03 +0200
changeset 0 c270c8b5ddea
permissions -rw-r--r--
Initial release. Usable.

<?php
/***** Informació de LOCALE *****/
echo setlocale(LC_ALL, 'ca_XX');
$textdomain = "butxaques";
bindtextdomain($textdomain, "./locale");
textdomain($textdomain);
bind_textdomain_codeset($textdomain, "utf-8");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title><?php echo _("Control de butxaques")." - "._("Nova butxaca");?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
</head>

<body>
<?php
echo "<h1 align=center>" . _("Control de butxaques") . "</h1>\n";
echo "<h2>" . _("Nova butxaca") . "</h2>\n";

include ("./strings.inc");

if (!isset($_POST["afegir"]))
{
?>

<FORM method=post action="update-butxaca">
<table>
<tr>
	<th><?php echo _("Nom de la butxaca") ?>
	<td><input type="text" name="nom" size=20 maxlength=50>
</table>
<center>
<input type=submit value="<?php echo _("Afegir butxaca");?>" name=afegir>
<input type=reset value="<?php echo _("Ressetejar formulari");?>">
</center>
</form>
<?php
}
else // if afegir
{
	// ****** Falta comprovar si el nom és NULL
	include("getdb.inc");

	// Fem la connexió
	$connexio = mysql_connect($mysql_server, $mysql_user,
	$mysql_password);
	mysql_select_db($mysql_db, $connexio);

	// Escrivim
	$query = "INSERT INTO butxaques (nom) VALUES('" .
		strtosql($_POST["nom"]) . "');";

	$resultat = mysql_query($query, $connexio);

	if (!$resultat)
	{
		echo "<p>";
		echo sprintf(_("<STRONG>ERROR:</STRONG> Error al actualitzar" .
			"les dades a <STRONG>%s</STRONG>!"), "butxaques");
		echo "</p>";
		echo mysql_errno().": ".mysql_error()."<BR>";
	}
	else
		echo _("<p>Inserció efectuada correctament.</p>");
}
?>

<p><A HREF="index"><?php echo _("Tornar al menú principal");?></A></p>

</body>
</html>