![Embarrassed :oops:](./images/smilies/icon_redface.gif)
god why am i soo stupid????
a was thinking about the design, but that is not important right now
![Smile :)](./images/smilies/icon_e_smile.gif)
.
anyway i tried to add a if thing to check if the postal number is alreadi in the DB, and it prints a error.
any ideas:
[syntax=php]
<?php
$connect = mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("ta2shop") or die(mysql_error());
// form data
$postal = $_POST['postal'];
$random = 'TA2_'.uniqid(rand(0123456789,9876543210));
$date = date("Y-m-d");
if(isset($_POST['generate'])) {
if($_POST['postal']) {
$query = mysql_query("INSERT INTO postal_codes VALUES('','$postal','$random','$date')") or die(mysql_error());
while($row = mysql_fetch_assoc($query)) {
if($row['postal']!= $postal) {
echo'<center>Succses, your traker code is: '.$random.' </center>';
}
else {
echo $random .'Already in Use';
}
}
}
else {
echo"<center>You must provide a postal code!</center>";
}
}
?>
[/syntax]
thanks