Hi..
I have made a form where I can type data for a database..
The problem is that when I open the Insert file in my browser, the script inserts a blank post in my database..
The script lookes like this..
<form method="post" action='<?=$_SERVER[PHP_SELF]?>'>
<tr><td width="100" align="right">Titel :</td><td><input type="text" size="40" maxlength="40" name="Titel"></td></tr>
<tr><td width="100" align="right">Komponist 1 :</td><td><input type="text" size="25" maxlength="25" name="Komponist1"></td></tr>
<tr><td width="100" align="right">Komponist 2 :</td><td><input type="text" size="25" maxlength="25" name="Komponist2"></td></tr>
<tr><td width="100" align="right">Komponist 3 :</td><td><input type="text" size="25" maxlength="25" name="Komponist3"></td></tr>
<tr><td width="100" align="right">Forfatter 1 :</td><td><input type="text" size="25" maxlength="25" name="Forfatter1"></td></tr>
<tr><td width="100" align="right">Forfatter 2 :</td><td><input type="text" size="25" maxlength="25" name="Forfatter2"></td></tr>
<tr><td width="100" align="right">Forfatter 3 :</td><td><input type="text" size="25" maxlength="25" name="Forfatter3"></td></tr>
<tr><td width="100" align="right">Email :</td><td><input type="text" size="25" maxlength="25" name="Kontakt"></td></tr>
<tr><td width="100" align="right">Lydklip :</td><td><input type="text" size="20" maxlength="20" name="Lydklip"></td></tr>
<tr><td width="100" align="right"><input type="submit" name="Submit" value="Submit"></td><td><select name="Stil">
<option>Pop</option>
<option>Rock</option>
<option>Country</option>
</select>
<select name="Hastighed">
<option>Ballade</option>
<option>Medium</option>
<option>Uptempo</option>
</select>
<select name="Sprog">
<option>Engelsk</option>
<option>Dansk</option>
</select>
<select name="Kvalitet">
<option>Færdig Produktion</option>
<option>Demo</option>
<option>Pre Demo</option>
</select></td></tr>
</form>
<?php
$conn = mysql_connect("localhost", "user", "pass");
mysql_select_db("database");
$titel = $POST['Titel'];
$komp1 = $POST['Komponist1'];
$komp2 = $POST['Komponist2'];
$komp3 = $POST['Komponist3'];
$forf1 = $POST['Forfatter1'];
$forf2 = $POST['Forfatter2'];
$forf3 = $POST['Forfatter3'];
$email = $POST['Kontakt'];
$lydkl = $POST['Lydklip'];
$stil = $POST['Stil'];
$tempo = $POST['Hastighed'];
$sprog = $POST['Sprog'];
$kvali = $_POST['Kvalitet'];
mysql_query ("INSERT INTO Titler (Titel, Komponist1, Komponist2, Komponist3, Forfatter1, Forfatter2, Forfatter3, Kontakt, Lydklip, Stil, Hastighed, Sprog, Kvalitet) VALUES ('$titel','$komp1','$komp2','$komp3','$forf1','$forf2','$forf3','$email','$lydkl','$stil','$tempo','$sprog','$kvali')");
mysql_close($conn);
?>
I guess I need a IF command before the insert line, so it only inserts if the form is submitted.. but how do I do that.. ??
best
Michael