www.webdeveloper.com
Results 1 to 4 of 4

Thread: PHP-MYSQL How to check if record already exists when UPDATING?

Threaded View

  1. #1
    Join Date
    Sep 2013
    Posts
    3

    PHP-MYSQL How to check if record already exists when UPDATING?

    PHP Code:
    if(mysql_num_rows($result)>0)
            {
                echo 
    'User already exists';                        
            }                
            else
            {
                if(isset(
    $_POST['editid']))
                {
                    
    $id=$_POST['editid'];
                    
                    
    /* check user already exists or not */
                    
    $temp=mysql_query("SELECT 1 FROM admin_login WHERE email = '$email' AND id != '$id'");                
                    
                    
    $query=mysql_query("update admin_login set username='$uname',password='$pass',email='$email',status='$status' where id='$id';");
                    
    /*else{}*/
                
    }
                else
                {            
                    
    $query=mysql_query("insert into admin_login(username,password,email,status)values('$uname', md5('$pass'), '$email', '$status');");            
                    echo 
    "New User Created Successfully";
                }
            } 
    Last edited by NogDog; 09-10-2013 at 11:16 AM. Reason: added [php] tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles