I have the following code in a PHP code in my contactform.php which what it does is take the data and insert it in a google sheet.
if(!empty($_SESSION['nombre'])) {
$dataAgregar = array('gclid' => $_SESSION['gclid'],
'nombre' => $_SESSION['nombre'],
'email' => $_SESSION['email'],
'telefono' =>"'" .$_SESSION['phone'],
'mensaje' => $_SESSION['mensaje'],
'landing' => $landingP
);
$listFeed->insert($dataAgregar);
}
if(!empty($_SESSION['nombre2'])) {
$dataAgregar2 = array('gclid' => $_SESSION['gclid2'],
'nombre' => $_SESSION['nombre2'],
'email' => $_SESSION['email2'],
'telefono' =>"'" .$_SESSION['phone2'],
'mensaje' => $_SESSION['mensaje2'],
'landing' => $landingP2
);
$listFeed->insert($dataAgregar2);
}
What I want to do is that if there is no gclid do not insert it in the google sheet, I thought about making the following code to perform this function.
if(empty($_SESSION['gclid'])){}
if(empty($_SESSION['gclid2'])){}/*Es porque tengo dos gclid*/
if(!empty($_SESSION['nombre'])) {
$dataAgregar = array('gclid' => $_SESSION['gclid'],
'nombre' => $_SESSION['nombre'],
'email' => $_SESSION['email'],
'telefono' =>"'" .$_SESSION['phone'],
'mensaje' => $_SESSION['mensaje'],
'landing' => $landingP
);
$listFeed->insert($dataAgregar);
}
if(!empty($_SESSION['nombre2'])) {
$dataAgregar2 = array('gclid' => $_SESSION['gclid2'],
'nombre' => $_SESSION['nombre2'],
'email' => $_SESSION['email2'],
'telefono' =>"'" .$_SESSION['phone2'],
'mensaje' => $_SESSION['mensaje2'],
'landing' => $landingP2
);
$listFeed->insert($dataAgregar2);
}
Would the code be fine to do what I want to do?