Showing posts with label PHP check if a value exists in my database table. Show all posts
Showing posts with label PHP check if a value exists in my database table. Show all posts

check if a value exists in my database table

Saturday, October 3, 2015

I want to check if a URL exists in my mySQL database table for example if Url=exist ,message=url already exist

      <?php
         if(isset($_POST['Submit']))
         {
            $dbhost = 'localhost';
            $dbuser = '####';
            $dbpass = '#######';
            $conn = mysql_connect($dbhost, $dbuser, $dbpass);
                        $Title = $_POST['Title'];
            $Url = $_POST['Url'];
                    $email_data = $_POST['email_data'];
            $type_data = $_POST['type_data'];
            $sql = "INSERT INTO table ". "(Title,Url,email_data,type_data)"."VALUES('$Title','$Url','$email_data','$type_data')";
            mysql_select_db('dbname');
            $retval = mysql_query( $sql, $conn );
            if(! $retval )
            {
               die('Could not enter data: ' . mysql_error());
            }
                         echo "alert('submitted successfully!')";
            mysql_close($conn);
         }
         else
         {
            ?>