Onbekend |
|
Hi, ik heb deze code:
<?php
$db_user = "user";
$db_pass = "pass";
$db_host = "localhost";
$db_db = "database";
mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_db);
if(isset($_POST['submit'])){
$email = $_POST['email'];
if(empty($_POST['email'])){
echo "U moet alle velden invullen";
}
$sql = "INSERT INTO mail(id,email) VALUES('".$_POST['email']."')";
$query = mysql_query($sql);
if($query == TRUE) {
echo "Uw mailadres is succesvol toegevoegd.";
}
else{
echo "Het is mislukt.";
}
}
else{
?>
<form method='post' action='mail.php'>
<input type='test' name='email'><br>
<input type='submit' name='submit' value='Ok'>
</form>
<?php
}
?>
<?php $db_user = "user"; $db_pass = "pass"; $db_host = "localhost"; $db_db = "database"; if(isset($_POST['submit'])){ $email = $_POST['email']; if(empty($_POST['email'])){ echo "U moet alle velden invullen"; } $sql = "INSERT INTO mail(id,email) VALUES('".$_POST['email']."')"; if($query == TRUE) { echo "Uw mailadres is succesvol toegevoegd."; } else{ } } else{ ?> <form method='post' action='mail.php'> <input type='test' name='email'><br> <input type='submit' name='submit' value='Ok'> </form> <?php } ?>
Maar ik krijg telkens "Het is mislukt".
Ik heb als SQL-code:
CREATE TABLE `mail` (
`id` INT NOT NULL AUTO_INCREMENT ,
`email` VARCHAR( 50 ) NOT NULL ,
PRIMARY KEY ( `id` )
) TYPE = MYISAM ;
`id` INT NOT NULL AUTO_INCREMENT , `email` VARCHAR( 50 ) NOT NULL , ) TYPE = MYISAM ;
Heeft iemand misschien een idee?
|