new to php and database stuff . I am required to make a system to record and save user data inside a database table that I called USER_INFO . the system works fine except when I make it inter User_ID (which is the only PRIMARY KEY data type) . whats more wierd to me is that when putting an id from inside the php code it takes it fine nd creates the new element , but when I make it take the data intered by a user in a form , it doesnt work .
Here is my PHP code to insert new data :
<?php
try {
    /*** connect to SQLite database ***/
    $dbh = new PDO("sqlite:ses.sdb");
    
    $sql = "SELECT * FROM USER_INFO";
    
    $Id_ok =$_GET['user_id'];  
    
        if($Id_ok != 0){
            foreach ($dbh->query($sql) as $row) {
                $name =$_GET['user_name'];
                $ID= $_GET['user_id'];
                $phone = $_GET['phone'];
                $address = $_GET['address'];
                $Email = $_GET['email'];
                
                // Just simple thing so I check the new elements
                print 'USER NAME='.$row['name']. ' ,  '.
                        'USER ID="'.$row['id']. '" ,  '.
                        'PHONE="'.$row['telephone']. '<br>';
            
                $sql2 = "INSERT INTO USER_INFO 
                            VALUES ('.$name.', '.$ID.', '.$phone.', 
                                    'work2', 'perhaps')"; // problrm here in $ID .
            
            
                $dbh->exec($sql2);
            }
        }
        echo "New record created";
      // Close the connetion 
        $dbh = null;
    } catch(PDOException $e) {
        echo $e->getMessage();
    }
?>
--the function I use to submit the form :
function Register(){
    
    if(userID_Ok_Register() == false){return;}
    
    users= new Array();
    
    for(var i=0;i<index;i++){
        users=user[i].split('#');
        if(users[2]==document.user_info.user_id.value){
            alert("ID alreadys exists");
            return;
        }   
        document.realForm.user_name.value = document.user_info.user_name.value;
        document.realForm.user_id.value = document.user_info.user_id.value; 
        document.realForm.phone.value = document.user_info.phone.value;
        document.realForm.address.value = document.user_info.address.value; 
        document.realForm.email.value = document.user_info.email.value;
    
        document.realForm.submit();
    }
}
I am also using WampServer , don't know if it matters or not , any help and tips helps alot :>
Tried to take user_id data and put it into a PRIMARY KEY slot in a database table .
I expected it to work as good as it did when I entered data from within the php code , as in I put 889 or such thing in the ID slot and it worked .
what actully happened is that it wouldn't take the user_ID that is taken from the form , and I have tested , The user_iD is fine , it just wouldn't be inserted into the database .
 
    