Undefined_index ajax call : <h2>Hi Hello Every One i Start A New Code But i can not figure out the error on my code</h2>

<p>The Code wen i send a call to my script like this
<a href="http://www.mywebsite.com/savedata.php?user_id=abc" rel="nofollow">http://www.mywebsite.com/savedata.php?user_id=abc</a></p>

<p>and this is my code</p>

<pre><code>&lt;?php
header('Access-Control-Allow-Origin: *');
error_reporting(E_ALL);
ini_set('display_errors',1);

$servername = "localhost";
$username = "user_name";
$password = "pass";

try {
    $conn = new PDO("mysql:host=$servername;dbname=mydb_name", $username, $password);
    // set the PDO error mode to exception
    $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    echo "Connected successfully"; 
}
catch(PDOException $e){
    echo "Connection failed: " . $e-&gt;getMessage();
}


if(isset($_GET['user_id'])){
     //$user_id = intval($_GET['user_id']);
     //Lightly sanitize the GET's to prevent SQL injections and possible XSS attacks

    try {
      $dbh = new PDO("mysql:host=$servername;dbname=db_name", $username, $password);

      $user_id = @$_GET['user_id'];  
      $dbh-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // &lt;== add this line
      $sql = "INSERT INTO users (user_id) VALUES ('".$_POST["user_id"]."')";
      if ($dbh-&gt;query($sql)) {
         echo "&lt;script type= 'text/javascript'&gt;alert('New Record Inserted Successfully');&lt;/script&gt;";
      }
      else{
         echo "&lt;script type= 'text/javascript'&gt;alert('Data not successfully Inserted.');&lt;/script&gt;";
      }    
      $dbh = null;
    }
    catch(PDOException $e){
       echo $e-&gt;getMessage();
    }

}
?&gt;

$sql-&gt;execute(array($user_Id));


     if($sql){         
          //The query returned true - now do whatever you like here.
          echo 'Your ID was saved. Congrats!';              
     }else{         
          //The query returned false - you might want to put some sort of error reporting here. Even logging the error to a text file is fine.
          echo 'There was a problem saving your points. Please try again later.';              
     }         
}else{
     echo 'Your id wasnt passed in the request.';
}

// close MySQL connection 
$conn = null;
?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;body bgcolor="#ffffff"&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
