title: Adding an entity to datastore with php
body: <p>I'm trying to add an entity to the datastore. Can anyone see where I'm going wrong? 
  I've been able to edit entities but unable to add one. </p>
  
  <p>register.php</p>
  
  <pre><code>        require_once __DIR__ . '/vendor/autoload.php';
  
          use Google\Cloud\Datastore\DatastoreClient;
          $projectId = "assignment-2-2020";
          $datastore = new DatastoreClient([ 'projectId' =&gt; $projectId]);
  
          $transaction = $datastore-&gt;transaction();
          $key = $datastore-&gt;key('user');
          $task = $transaction-&gt;lookup ($key);
          $task['Name/ID'] = $_POST['id'];
          $task['name'] = $_POST['name'];
          $task['password'] = $_POST['password'];
          $transaction-&gt;update($task);
          $transaction-&gt;commit();    
  
  $_SESSION['username'] = $_POST['name'];
  
  if (!is_null($_POST['name'])) {
  echo '&lt;script type="text/javascript"&gt;
  window.location = "/main.php"
  &lt;/script&gt;';
  }
  
  ?&gt;
  </code></pre>
  
  <p>Here is my Datastore</p>
  
  <p><a href="https://i.stack.imgur.com/aS9ke.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aS9ke.png" alt="enter image description here"></a></p>