Hallo allemaal. Ik heb een query probleem(pje).
Ik heb een formulier dat gegevens in de database schrijft. Maar... Ik wil die gegevens verifiëren of ze al bestaan. Er moeten 3 velden gecheckt worden:
1. Type; <- als ja check 2.
2. coordinates1; (+ of - 2 van bestaand record) <- als ja check 3. Als nee: insert record en echo "Mine posted succesfully in the database!"
3. coordinates2. (+ of - 2 van bestaand record) <- als ja echo "There is allready a mine of this type in the database on that location!"
(één coordinaat bestaat uit xxxxxx,xxx).
Een vergelijking-query voor 1 variable kan ik wel vinden. Maar een query voor 3 niet en ook niet hoe ik de + of - 2 vergelijking moet opbouwen.
Wie kan me helpen?!
Christiaan
Ik heb een formulier dat gegevens in de database schrijft. Maar... Ik wil die gegevens verifiëren of ze al bestaan. Er moeten 3 velden gecheckt worden:
1. Type; <- als ja check 2.
2. coordinates1; (+ of - 2 van bestaand record) <- als ja check 3. Als nee: insert record en echo "Mine posted succesfully in the database!"
3. coordinates2. (+ of - 2 van bestaand record) <- als ja echo "There is allready a mine of this type in the database on that location!"
(één coordinaat bestaat uit xxxxxx,xxx).
Een vergelijking-query voor 1 variable kan ik wel vinden. Maar een query voor 3 niet en ook niet hoe ik de + of - 2 vergelijking moet opbouwen.
Wie kan me helpen?!
Christiaan
Code:
<?
include 'mining_cfg.php';
// html collect variable
$type = $_POST['type'];
$level = $_POST['level'];
$coordinates1 = $_POST['coordinates1'];
$coordinates2 = $_POST['coordinates2'];
if ($type == ".$type") AND if ($coordinates1 == ".$coordinates1") AND if ($coordinates2 == ".$coordinates2"){
echo "Mine posted succesfully!";
} else {
echo "There is allready a mine of this type in the database on that location!";
}
// sql insert into database
$sql ="INSERT INTO mining(type, level, coordinates1, coordinates2)
VALUES ('".$type."', '".$level."', '".$coordinates1."', '".$coordinates2."')";
//uitvoeren van de query :
if (!($temp = mysql_query($sql,$connection)))
showerror();
header ( "Location: http://swr.infiniteserve.com/swr-site/test/post_mining.php" );
?>