hello there, hope someone can help me with this ... <?php $dbtable = 'atx_tags'; $db_conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $db_found = mysql_select_db($dbname); if(isset($_POST['submit'])){ $Tag = $_POST['Tag']; $Date = date('Y-m-d'); $query = "INSERT INTO " . $dbtable . " (Tag,Date) VALUES ('$Tag','$Date')"; mysql_query($query); } ?> <form action="" method="post"> <input name="Tag" class="input" type="text"><br> <input type="submit" name="submit" class="input2" value="Submit"> </form> PHP: how i can make if Tag is already added on atx_tags to dont add again and to show echo error video already added ! ... hope someone can help me with this ...
It will be something like this: Not tested though <?php $dbtable = 'atx_tags'; $db_conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $db_found = mysql_select_db($dbname); if(isset($_POST['submit'])){ $Tag = $_POST['Tag']; $Date = date('Y-m-d'); } $result = mysql_query("SELECT Tag FROM " . $dbtable . " WHERE Tag='$Tag';") or die(mysql_error()); if(mysql_num_rows($result) == 0) { $query = "INSERT INTO " . $dbtable . " (Tag,Date) VALUES ('$Tag','$Date')"; mysql_query($query); } else { echo "Tag already exist, please try again"; } ?> PHP: