Wiatam dopiero aczynam zabawe z php, mam dwa skrypty. pierwszym jest formularz który wysyła dane do drugiego skryptu który sprawdza paprawność danych i zapisuje je do bazy mysql, jeżeli dane nie sa poprawne odsyła komunikat do skryptu z formularzem o niepoprawnośći danych, kombinuje we wszystkie strony ale nie działa:/ nie zapisuje danych ani nie wyswietla komunikatów, prosze o pomoc.
skrypt 1 (index.php)<form action="dodaj.php?action=add&type=song&id=" method="post">
<? if ($_GET['error']) {
echo "<div align=\"center\" " . "style=\"color:#ff0000;background-collor:#ff0000;" .
"</div><br />";
}
?>
<table border="0" width="750" cellspacing="1" cellpadding="3"
bgcolor="#353535" align="center">
<tr>
<td bgcolor="#ffffff" width="30%">Imie:</td>
<td bgcolor="#ffffff" width="70%">
<input type="text" name="imie" >
</td>
</tr>
<tr>
<td bgcolor="#ffffff" width="30%">Nazwisko</td>
<td bgcolor="#ffffff" width="70%">
<input type="text" name="nazwisko" >
</td>
</tr>
<tr>
<td bgcolor="#ffffff" width="30%">Email</td>
<td bgcolor="#ffffff" width="70%">
<input type="text" name="email" >
</td>
</tr>
<tr>
<td bgcolor="#ffffff" width="30%">telefon</td>
<td bgcolor="#ffffff" width="70%">
<input type="text" name="telefon" >
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" colspan="2" align="center">
<input type="submit" value="Dodaj">
</td>
</tr>
</table>
</form>
skrypt 2 (dodaj.php)<?
$error = '';
switch ($_GET['action']) {
case "add";
switch ($_GET['type']){
case "telefon";
if ($_POST["email"] &&
!ereg("^[^@]+@([a-z-]+.)+[a-z]{2,4}$", $_POST[ "email"])) $error .= "Nieprawidłowy adres e-mail.";
if (empty($_POST['imie'])) { $error .= "WYBIERZ+WYKONAWCE";
}
if (empty($_POST['nazwisko'])) { $error .= "WYBIERZ+ROK+PREMIERY";
}
if (empty($_POST['telefon'])) { $error .= "PODAJ+NAZWE+ALBUMU";
}
$sql = "INSERT INTO tabela
(imie,
nazwisko,
email,
telefon)
VALUES
('" . $_POST['imie'] . "',
'" . $_POST['nazwisko'] . "',
'" . $_POST['email'] . "',
'" . $_POST['telefon'] . "')";
}
else {
header("location:index.php?action=add&error=" . $error); }
break;
}
break;
}
?>
<p align="center" style="color:#FF0000">
Wykonane. <a href="index.php">lista</a></p>
<?
}
?>