Hi guys... I have this page I'm trying to get to work, but no matter what I do it doesn't want to insert a new post into the database. Help? Please?
<?php
//ansluter till databasen
$opendb=mysql_connect("****", "*****", "****") or die(mysql_error());
mysql_select_db("*****") or die(mysql_error());
//skriver information till den angivna tabellen om den är uppdaterad
if(isset($_POST['submit'])){
$nypost = mysql_query("INSERT INTO arkentider (typ) VALUES('$_POST[typ]')")
or die("Kunde inte lägga till ny räkning:<br />".mysql_error());
}
//Hämtar intervall att lista
if(isset($_POST['Sok'])){
$Start=$_POST['Startdatum'];
$Slut=$_POST['Slutdatum'];
$today = date("Y-m-d");
$sql = "SELECT * FROM arkentider WHERE DATE(tid) >= '".$Start."' AND DATE(tid) <= '".$Slut."' ORDER BY tid DESC";
$result = mysql_query($sql) or die(mysql_error());
}
else {
$sql = "SELECT * FROM arkentider ORDER BY tid DESC";
$result = mysql_query($sql) or die(mysql_error());
}
//Lägger till post
echo "<form action='".$PHP_SELF."' method='post'>";
echo "<select name='typ'>";
echo "<option selected>Gått på lunch</option>";
echo "<option>Kommit tillbaka från lunch</option>";
echo "<option>Kompat ut</option>";
echo "</select>";
echo "<input type='submit' value='Registrera'><input type='Reset' value='Rensa'>";
echo "</form>";
//Väljer intervall att lista
echo "<form action='".$PHP_SELF."' method='post'>";
echo "Startdatum: <input type='date' name='Startdatum' value='".$Start."'> Slutdatum: <input type='date' name='Slutdatum' value='".$Slut."'> <input type='submit' value='Sök' name='Sok'>";
echo "</form><BR><BR>";
//Listar poster i det angivna intervallet
echo "<style type='text/css'>tr:hover { background:#3fc9fc; }</style>";
echo "<table border='1' bordercolor='#3fc9fc' cellspacing='0' cellpadding='3' width='90%'>";
echo "<tr bgcolor='#3fc9fc'>";
echo "<td align=center valign=center style='white-space:nowrap'>";
echo "Tid";
echo "</td>";
echo "<td align=center valign=center style='white-space:nowrap'>";
echo "Vad";
echo "</td>";
echo "</tr>";
while($row = mysql_fetch_array( $result ))
{
echo "<tr>";
echo "<td style='white-space:nowrap'><FONT SIZE=2>";
echo $row['tid'];
echo "</FONT></td>";
echo "<td style='white-space:nowrap'><FONT SIZE=2>";
echo $row['text'];
echo "</FONT></td>";
echo "</tr>";
}
echo "</table>";
//stänger databasen
mysql_close($opendb);
?>
Is it the double forms that mess me up or what?