<?
include ('config.php');
function SpaceEraser($text)
{
for ($i=0;$i<=strlen($text);$i++)
if (ord($text[$i]) != 32
)
$newStr .= $text[$i];
return $newStr;
}
function pulisciRighe($array)
{
$k = 0;
foreach ($array as $val)
{
if (ord(spaceEraser
($val))!=13
)
$newArray[] = $val;
}
return $newArray;
}
function creaSondaggio($titolo,$testo)
{
include_once('connetti.php');
for ($i=0;$i<$nRighe;$i++)
$voti[] = '0';
$insert = mysql_query("insert into sondaggi (titolo,voci,dataCreazione,votazione) VALUES('$titolo','".implode("\r\n",$testo)."','$data','$voti')");
return $insert;
}
if (isset($_POST['submit']))
{
$testo = $_POST['textarea'];
$testo = pulisciRighe
(explode("\n",$testo));
if ((count($text) == 0
&& $testo[0] == '') || ($_POST['title'] == ''))
{
if (count($text) == 0
&& $testo[0] == '')
$errore = 'Inserire le voci del sondaggio';
if ($_POST['title'] == '')
$errore = 'Inserire un titolo al sondaggio';
}
else
{
if (creaSondaggio($_POST['title'],$testo))
{
header('location: lista.php');
}
else
$errore = 'Errore nella creazione del sondaggio';
}
}
?>
<html>
<head>
<title>Crea un tuo sondaggio</title>
</head>
<form action="" method="post">
<div style="width: 510px; border:1px solid;">
<label for="title">Titolo:</label><br />
<input type="input" name="title" id="title" style="width: 503px" /></br><br />
<label for="textarea">Inserire nel box sottostante le opzioni del sondaggio (1 per riga)</label><br />
<textarea type="textarea" rows="20" cols="60" name="textarea" id="textarea"></textarea><br />
<input style="margin: 0 150px auto;" type="submit" name="submit" value="Invia Sondaggio">
<br />
<span style="color:red"><? echo $errore ?></span>
</div>
</form>