(war mein erstes eigenes php script)
Dann wunder mich das nicht, denn das is falsch was du da geschrieben hast.
ich würde das so machen:
Also erstmal würde ich nur ein Textfeld benutzen, und dieses "email" nennen.
PHP
<?php
/**
* @author
* @copyright 2009
*/
if(isset($POST_[submit]) && !empty($_POST[email]))
{
include ('db.php');
$enthalten = false;
$email = $_POST[email];
$sql = "SELECT name FROM tabelle";
$query = mysql_querry($sql);
while($row = mysql_fetch_object($query))
{
if($row->mail == $email)
{
$enthalten = true;
}
}
if($enthalten)
{
$sql2 = "DELETE FROM tabelle WHERE mail = '$email' ";
if(mysql_query($sql2))
{
echo "Erfolgreich gelöscht";
}
}
else
{
$sql2 = "INSERT INTO tabelle(mail) VALUES('$email')";
if(mysql_query($sql2))
{
echo "Erfolgreich hinzugefügt";
}
}
}
?>
Alles anzeigen