|
here's my script:
<?php
$name=$_POST['name'];
$email=$_POST['email'];
$pass=$_POST['pass2'];
$year=$_POST['year'];
$month=$_POST['month'];
$day=$_POST['day'];
$skype=$_POST['skype'];
$yahoo=$_POST['yahoo'];
if ($name == "" || $email == "" || $pass == "") {
echo "Please fill in all the fields";
}
$username = "username";
$password = "password";
$host = "localhost";
mysql_connect($host,$username,$passwor... or die("No connect");
mysql_select_db("dbname") or die("Unable to select database");
$query = "INSERT INTO members VALUES
('','$name','$email','$pass','$year','...
mysql_query($query) or die(mysql_error());
$ok = "<html><head><title>ok</title></head><bo...
if (mysql_query($query)) {
echo($ok);
}
else {
}
?>
Why does my php script create two entries in my mysql db for every form submitted?
You are calling mysql_query($query) twice - once after you declare it, and again inside the if block. You should do something like $result = mysql_query($query) or die....
|