jasmen
06.01.2004, 01:13
Hallo,
stehe schon wieder auf dem Schlauch!
Ich möchte mit dem folgenden Script ein Dialogfenster mit zwei Buttons für "OK" und "Abbrechen" ausgeben
- das funktioniert.
Wenn man auf OK drückt, kommt man weiter und die Werte werden abgespeichert.
Aber wenn man auf Abbrechen geht, kommt man zwar zurück, aber die Werte werden trotz der negativen Entscheidung in die DB gespeichert!
Was ist hier falsch???? ?(
<?php
$query=mysql_query("SELECT id FROM inventor WHERE firstname='$firstname'&&lastname='$lastname'");
if (!$query)
echo mysql_error();
$number=mysql_num_rows($query);
if ($number>0) //Check if the inventor with these lastname/firstname already in the DB
{
echo "<html><head><title>Create New Inventor</title>";
?>
<script type="text/javascript">
Check = confirm("The Inventor <?php echo $firstname." ".$lastname; ?> is already in the DB! Continue?");
if(Check == false) history.back();
//-->
</script
<?php
}
echo "</head><body>";
//insert a new inventor into the database
$sql=mysql_query("INSERT INTO inventor (firstname, lastname, citizenship, street,".
" town, country, lab, p_group,email, phone_home, phone_office, comment)".
" VALUES ('$firstname', '$lastname', '$citizenship', '$street', '$town', '$country', '$lab', '$p_group',".
" '$email','$phone_home', '$phone_office', '$comment')");
if (!$sql)
echo mysql_error();
echo "</body></html>";
?>
Danke
jasmen
stehe schon wieder auf dem Schlauch!
Ich möchte mit dem folgenden Script ein Dialogfenster mit zwei Buttons für "OK" und "Abbrechen" ausgeben
- das funktioniert.
Wenn man auf OK drückt, kommt man weiter und die Werte werden abgespeichert.
Aber wenn man auf Abbrechen geht, kommt man zwar zurück, aber die Werte werden trotz der negativen Entscheidung in die DB gespeichert!
Was ist hier falsch???? ?(
<?php
$query=mysql_query("SELECT id FROM inventor WHERE firstname='$firstname'&&lastname='$lastname'");
if (!$query)
echo mysql_error();
$number=mysql_num_rows($query);
if ($number>0) //Check if the inventor with these lastname/firstname already in the DB
{
echo "<html><head><title>Create New Inventor</title>";
?>
<script type="text/javascript">
Check = confirm("The Inventor <?php echo $firstname." ".$lastname; ?> is already in the DB! Continue?");
if(Check == false) history.back();
//-->
</script
<?php
}
echo "</head><body>";
//insert a new inventor into the database
$sql=mysql_query("INSERT INTO inventor (firstname, lastname, citizenship, street,".
" town, country, lab, p_group,email, phone_home, phone_office, comment)".
" VALUES ('$firstname', '$lastname', '$citizenship', '$street', '$town', '$country', '$lab', '$p_group',".
" '$email','$phone_home', '$phone_office', '$comment')");
if (!$sql)
echo mysql_error();
echo "</body></html>";
?>
Danke
jasmen