title: Check if all the field are filled, if yes then login via Google and save records of the fields PHP
body: <p>I have a form in PHP HTML in which the user fills some fields on button press I want to check if all the fields are filled, if yes then check if the user is logged in, if yes then save records if no then proceed to google login procedure save user credentials and save the input filed records</p>
  
  <p>input page as evaluate.php</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;script&gt;
  function SaveReview(){
   //alert("I am here");
   var UserId    = document.getElementById('UserId').value; 
   var company   = document.getElementById('company').value; 
   var Id    = document.getElementById('Id').value; 
   var star    = document.getElementById('star').value; 
   var review    = document.getElementById('review').value; 
   var reviewtitle  = document.getElementById('reviewtitle').value; 
   var infoemail  = document.getElementById('infoemail').checked;
   var email   = document.getElementById('email').value; 
   var domain   = document.getElementById('domain').value; 
  // alert(infoemail);
   if(UserId == 0){
   
   alert("Please Login First and then try again");
   return false;
   } 
   else if(star == "-- Please Select --"){
   alert("Please select Star rating"); 
   return false;
   } 
   else if(review == 0){
   alert("Please Enter Review");
   return false;
   } 
   else if(reviewtitle == 0){
   alert("Please Enter Title for Review");
   return false;
   } 
   else{
   //alert("Sb sahi hai");
   document.getElementById('savereview').submit();
   } 
   //alert(domain);
  }
  
  &lt;/script&gt;</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>&lt;style&gt;
  .btn-facebook{
   background-color:#5c76a9}
  .btn-google{
   background-color:#DC4437}
  &lt;/style&gt;</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  include("dblocal.php");
  $UserId = $_SESSION["usersessionid"];
  if(isset($_REQUEST["CompanyId"])){ 
  $CompanyId = $_REQUEST["CompanyId"];
  }
  if(isset($_REQUEST["website"])){
  $website = $_REQUEST["website"];
  }
  $sql  = "SELECT Id, CompanyName, EmailId FROM company WHERE Id = $CompanyId";
  $result = $conn-&gt;query($sql);
  //echo $sql;
  $row = $result-&gt;fetch_assoc();
  $Id     = $row["Id"];
  $CompanyName = $row["CompanyName"];
  $EmailId   = $row["EmailId"]; 
  
  $EPos  = strpos($EmailId,"@");
  $Int  = substr($EmailId,0,$EPos);
  $Domain = substr($EmailId,$EPos);
  //echo $EmailId;
  $EmailValue = $Int."".$Domain;         
  ?&gt;
  
  &lt;div class=""&gt;
      &lt;!--&lt;div class="tm-section tm-section-pad tm-bg-img" id="tm-section-5"&gt;--&gt;
      &lt;div class="tm-section tm-section-pad tm-bg-img"&gt;
          &lt;div class="container ie-h-align-center-fix"&gt;
              &lt;div class="row tm-flex-align-center"&gt;
                &lt;div class="col-sm-10 col-sm-offset-1"&gt;
                      &lt;div class="row"&gt;
                       &lt;div class="col-sm-8"&gt;
         &lt;h3 class="category-heading" &gt;Voice your opinion! Review &lt;a href="&lt;?php echo base_url(); ?&gt;/company?CompanyId=&lt;?php echo $Id; ?&gt;"&gt;&lt;?php echo $CompanyName; ?&gt;&lt;/a&gt; now. &lt;/h3&gt;
                              &lt;div class="reviewsection"&gt;
                                  &lt;form method="post" id="savereview" action="&lt;?php echo base_url(); ?&gt;savereview"&gt;
                                  &lt;div class="row"&gt;
                                  &lt;input type="hidden" name="Option" id="Option" value="Add" /&gt;
                                   &lt;div class="col-sm-6"&gt;
                                       &lt;input type="hidden" class="form-control" name="UserId" id="UserId" value="&lt;?php echo $UserId; ?&gt;" /&gt;
                                       &lt;input type="hidden" class="form-control" name="Id" id="Id" value="&lt;?php echo $Id; ?&gt;" /&gt;
                                          &lt;?php 
            if(isset($CompanyName)){?&gt;
                                       &lt;input type="hidden" class="form-control" name="company" id="company" value="&lt;?php echo $CompanyName; ?&gt;" placeholder="Enter Company Name" /&gt;
                                          &lt;?php
            }
            else{?&gt;
             &lt;input type="text" class="form-control" name="company" id="company" value="" placeholder="Enter Company Name" /&gt; 
                                              &lt;input type="text" class="form-control" name="website" id="website" value="&lt;?php echo $website; ?&gt;" placeholder="Enter website Url" readonly="readonly" /&gt;
                                          &lt;?php }?&gt;
                                      &lt;/div&gt;
                                      &lt;div class="col-sm-6"&gt;
            &amp;nbsp;
                                          &lt;!--&lt;p class="reviewheading"&gt;Website&lt;/p&gt;
                                       &lt;input type="text" class="form-control" name="website" id="website" value="&lt;?php //echo $CompanyName; ?&gt;" placeholder="Enter Company Name" /&gt;--&gt;
                                      &lt;/div&gt;
                                   &lt;div class="col-sm-12"&gt;
                                       &lt;p class="reviewheading"&gt;Your Review&lt;/p&gt;
                                       &lt;select class="form-control" name="star" id="star"&gt;
                                           &lt;option selected="selected" disabled="disabled"&gt;-- Please Select -- &lt;/option&gt;
                                           &lt;option&gt;1&lt;/option&gt;
                                              &lt;option&gt;2&lt;/option&gt;
                                              &lt;option&gt;3&lt;/option&gt;
                                              &lt;option&gt;4&lt;/option&gt;
                                              &lt;option&gt;5&lt;/option&gt;
                                          &lt;/select&gt;
                                      &lt;/div&gt;
                                      &lt;div class="col-sm-6"&gt;
                                          &lt;p class="reviewheading"&gt;Rating&lt;/p&gt;
                                          &lt;span class="text4"&gt;
                                              &lt;span class="fa fa-star checked" id="fivestar" style="font-size:150%; padding:2%"&gt;&lt;/span&gt;
                                              &lt;span class="fa fa-star checked" id="fivestar" style="font-size:150%; padding:2%"&gt;&lt;/span&gt;
                                              &lt;span class="fa fa-star checked" id="fivestar" style="font-size:150%; padding:2%"&gt;&lt;/span&gt;
                                              &lt;span class="fa fa-star checked" id="fivestar" style="font-size:150%; padding:2%"&gt;&lt;/span&gt;
                                              &lt;span class="fa fa-star checked" id="fivestar" style="font-size:150%; padding:2%"&gt;&lt;/span&gt;
                                          &lt;/span&gt;
                                      &lt;/div&gt;
                                      &lt;div class="col-sm-4"&gt;
                                          &lt;p class="text4"&gt;&amp;nbsp;&lt;/p&gt;
                                          &lt;p&gt;Roll over stars, then click to rate.&lt;/p&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  &lt;div class="row"&gt;
                                      &lt;div class="col-sm-12"&gt;
                                       &lt;p class="reviewheading"&gt;Your Review&lt;/p&gt;
                                       &lt;textarea class="form-control" name="review" id="review" rows=10 placeholder="Share your honest Experience and help others make better choices"&gt;&lt;/textarea&gt;
                                      &lt;/div&gt;
                                      &lt;div class="col-sm-12"&gt;
                                       &lt;p class="reviewheading"&gt;Review Title&lt;/p&gt;
                                          &lt;div class="input-group"&gt;
                                              &lt;input type="text" class="form-control" name="reviewtitle" id="reviewtitle" style="font-size:100%;" placeholder="Review Title" name="search"&gt;
                                              &lt;div class="input-group-btn"&gt;
                                               &lt;button class="btn btn-default" type="button"&gt;&lt;i class="glyphicon glyphicon-edit"&gt;&lt;/i&gt; Edit&lt;/button&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                      &lt;div class="col-sm-12"&gt;&lt;br /&gt;
                                          &lt;label class="checkbox-inline"&gt;&lt;input type="checkbox" value="" name="infoemail" id="infoemail"&gt;Let &lt;?php echo "Company"; ?&gt; know about your review. Just check the box and we'll notify them. &lt;/label&gt;
                                          &lt;p&gt;The review will be sent to:&lt;/p&gt;
                                          &lt;div style="background-color:#999; padding:2%"&gt;
                                          &lt;input type="text" name="email"  id="email" value="&lt;?php echo $Int; ?&gt;"/&gt;&lt;?php echo $Domain; ?&gt;
                                          &lt;input type="hidden" name="domain" id="domain" value="&lt;?php echo $Domain; ?&gt;" /&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                      &lt;?php
           if(isset($UserId)){
            ?&gt;
                                          &lt;div class="col-sm-12"&gt;&lt;br /&gt;
            &lt;input type="button" class="btn btn-warning btn-block" onclick="SaveReview();" value="Post your review Now"/&gt;     
            &lt;/div&gt;
            &lt;?php
           }else{
           ?&gt;
                                      &lt;div class="row"&gt;
                                      &lt;div class="col-sm-12" align="center"&gt;
                                      &lt;h4&gt;&lt;strong&gt;Post and Verify Yourself with&lt;/strong&gt;&lt;/h4&gt;&lt;/div&gt;
                                          &lt;div class="col-sm-4"&gt;
             &lt;button type="button" onclick="SaveReview();" class="btn btn-default btn-block btn-login btn-facebook"&gt;&lt;i class="fab fa-facebook-f"&gt;&lt;/i&gt;&amp;nbsp;Log in with Facebook&lt;/button&gt;&lt;/a&gt;     
                                          &lt;/div&gt;
                                          &lt;div class="col-sm-4"&gt;
                                          &lt;!--&lt;a href="&lt;?= 'https://accounts.google.com/o/oauth2/auth?scope=' . urlencode('https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/plus.me') . '&amp;redirect_uri=' . urlencode(CLIENT_REDIRECT_URL) . '&amp;response_type=code&amp;client_id=' . CLIENT_ID . '&amp;access_type=online' ?&gt;" id="googlelogin"&gt;&lt;button type="button" onclick="SaveReview();" class="btn btn-default btn-block btn-google"&gt;&lt;i class="fab fa-google-plus-g"&gt;&lt;/i&gt;&amp;nbsp;Log in with Google&lt;/button&gt;&lt;/a&gt;  --&gt;
                                         &lt;button type="button" onclick="SaveReview();" class="btn btn-default btn-block btn-google"&gt;&lt;i class="fab fa-google-plus-g"&gt;&lt;/i&gt;&amp;nbsp;Log in with Google&lt;/button&gt;
                                          &lt;/div&gt;
                                          &lt;div class="col-sm-4"&gt;
                                          &lt;button class="btn btn-default btn-block" onclick="SaveReview();"&gt;&lt;i class="fas fa-envelope"&gt;&lt;/i&gt;&amp;nbsp;Email&lt;/button&gt;   
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                      &lt;?php
           } ?&gt;
                               &lt;/div&gt;
                              &lt;/div&gt;
                              &lt;/form&gt;
                          &lt;/div&gt;
                          
                          &lt;div class="col-sm-4"&gt;&lt;br /&gt;
                          &lt;p&gt; 
                          &lt;h4 class="colorblue"&gt;What is Trustpilot?&lt;/h4&gt;
                          Trustpilot is a review community. We help consumers everywhere find companies they can trust.
                          &lt;/p&gt;
                          &lt;p&gt;
                          &lt;h4 class="colorblue"&gt;Share your experiences&lt;/h4&gt;
                          and be a part of our community. It couldn't be easier - with your Trustpilot account you can write, edit and share your reviews from one convenient location.
                          &lt;/p&gt;
                          &lt;/div&gt;
                          
                      &lt;/div&gt;
                
                  &lt;/div&gt;
              &lt;/div&gt;            
          &lt;/div&gt;
      &lt;/div&gt;
      
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>