I have several values in cloud firestore and want to access every variables. Hence I do my code like this
<?php
require __DIR__.'/vendor/autoload.php';
use Google\Cloud\Firestore\FirestoreClient;
$db = new FirestoreClient(
[
'projectId' => 'fakedata-aa798'
]
);
$collectionReference = $db->collection('Test3');
$docRef = $collectionReference->document('User1');
$snapshot = $docRef->snapshot();
$Name= $snapshot['Name'];
$Contact= $snapshot['Contact no:'];
$Email= $snapshot['Email'];
$Location= $snapshot['Location'];
$Locationstatus= $snapshot['Location status'];
$Condition= $snapshot['Condition'];
session_start();
$_SESSION['Name'] = $Name;
$_SESSION['Contact no:'] = $Contact;
$_SESSION['Email'] = $Email;
$_SESSION['Location'] = $Location;
$_SESSION['Location status'] = $Locationstatus;
$_SESSION['Condition'] = $Condition;
?>
Now I want to display the values in next PHP files and I use session_start but still can't get the values
pages2
<?php
session_start();
echo $_SESSION['Name'];
?>
Can someone help me?
Related
i am getting issue in PUT method. But everything is fine when i'm doing method post
here is some code :
<?php
header("Content-type: multipart/form-data");
include_once '../Database/database.php';
$status = array();
if(is_uploaded_file($_FILES["ImageKTP"]["tmp_name"]))
{
$tmp_file = $_FILES["ImageKTP"]["tmp_name"];
$ImageKTP = $_FILES["ImageKTP"]["name"];
$upload_dir = "./uploads/" .$ImageKTP;
if (move_uploaded_file($tmp_file, $upload_dir)) {
$status['kode']=1;
$status['deskripsi']='upload success';
$ImageKTP = $upload_dir;
} else {
$status['kode']=0;
$status['deskripsi']='upload failed';
$ImageKTP = null;
}
}
echo json_encode($status);
?>
But when i'm doing method put using application/json, the result is failed
<?php
header("Content-type: application/json");
include_once '../Database/database.php';
include_once '../Controller/users.php';
$data = json_decode(file_get_contents('php://input'), true);
$email=$data['email'];
$idcardnumber=$data['idcardnumber'];
$placeofbirth=$data['placeofbirth'];
$dateofbirth=$data['dateofbirth'];
$Gender=$data['Gender'];
$Religion=$data['Religion'];
$ImageKTP=$data['ImageKTP'];
$ImageSelfie=$data['ImageSelfie'];
$ImageFamilyMemberCard=$data['ImageFamilyMemberCard'];
$database = new Database();
$db = $database->getConnection();
$user = new Users($db);
$stmt = $user->UpdateProfile($email, $idcardnumber, $placeofbirth, $dateofbirth, $Gender, $Religion, $ImageKTP, $ImageSelfie, $ImageFamilyMemberCard);
if($stmt->rowCount() > 0){
// create array
$profile_arr=array(
"success" => 1,
"message" => "Successfully Update Profile!"
);
}
else{
$profile_arr=array(
"success" => 0,
"message" => "Update Profile Failed!",
);
}
print_r(json_encode($profile_arr));
?>
I still didnt find out how to solve this problem cause i want to update profile using method PUT include other value
The $_FILES array only works with POST requests. If you want to use PUT there are some configurations to the web server that need to be made first, you can find a detailed guide here.
Good Day
I am not sure if this is possible but any advice would be greatly be appreciated.
I have a code in PHP as below and would like to add additional PHP code Not sure how to explain it but maybe if I show code it would make some sence.
<?php
//Clickatell login
$user = "##";
$password = "##";
$api_id = "##";
$baseurl ="http://api.clickatell.com";
$text = urlencode("Recovery Assist Panic Activated (BETA TEST VERSION");
$to = "'0827910119'";
?>
The above is the current code I have with some additional extra's not required here. I want to add the following to this code as part of Sitelok page manager
<?php
//Clickatell login
$user = "##";
$password = "##";
$api_id = "##";
$baseurl ="http://api.clickatell.com";
$text = urlencode("Recovery Assist Panic Activated (BETA TEST VERSION");
<?php if (sl_ismemberof("RecAssist")){ ?>
$to = "'0827911119'";
<?php } ?>
<?php if (sl_ismemberof("Gold")){ ?>
$to = "'0827952558'";
<?php } ?>
?>
The "is a member of" is part of the sitelok code to exclude on HTML where a person does not have access to. I am not sure if I can run another inside the one running already. I know this can be done with IF and ELS most prob but the coding for the amount of groups will just be too much so hoped that somehow I can use the Sitelok section
Why not just use an if statement?
e.g.
<?php
//Clickatell login
$user = "##";
$password = "##";
$api_id = "##";
$baseurl = "http://api.clickatell.com";
$text = urlencode("Recovery Assist Panic Activated (BETA TEST VERSION");
if (sl_ismemberof("RecAssist")){
$to = "'0827911119'";
} elseif (sl_ismemberof("Gold")) {
$to = "'0827952558'";
}
?>
The best an most maintainable way to achieve this would be to define all of your groups or w/e in an associative array and loop through it because it will be the most maintainable.
<?php
//Clickatell login
$user = "##";
$password = "##";
$api_id = "##";
$baseurl = "http://api.clickatell.com";
$text = urlencode("Recovery Assist Panic Activated (BETA TEST VERSION");
$groups = array(
"RecAssist" => "0827911119",
"Gold" => "0827952558",
);
$to = "";
foreach($groups as $k=>$v)
{
if(sl_ismemberof($k)) // $k is the RecAssist or Gold or w/e
{
$to = "'$v'"; // $v is those digits
// if $groups were to have 100 items or even 1,000 then there is no need to run sl_ismemberof() on the remaining items once we found what we are looking for. It would be a waste of time.
break; // break out of our loop
}
}
echo $to;
?>
<?php
include_once 'vtlib/Vtiger/Utils.php';
require_once('include/database/PearDatabase.php');
require_once 'config.inc.php';
require_once 'includes/Loader.php';
require_once 'modules/SMSNotifier/SMSNotifier.php';
vimport ('includes.runtime.EntryPoint');
$user = Users_Record_Model::getCurrentUserModel();
GLOBAL $adb;
$tonumbers = array('994255xxxx');
$message = "Test From Ramesh";
$provider = SMSNotifierManager::getActiveProviderInstance();
if( $provider ){
$provider->send($message, $tonumbers);
}
?>
Get provider instance using getActiveProviderInstance. and call send function from that instance.
Try this
<?php
include_once 'includes/main/WebUI.php';
require_once 'includes/Loader.php';
require_once 'modules/SMSNotifier/SMSNotifier.php';
$tonumbers = array('994255xxxx');
$message = "Test From Ramesh";
SMSNotifier::fireSendSMS($message, $tonumbers);
Hi there I'm trying to write a .php file using this code, server replying this error : syntax error, unexpected '0' (T_LNUMBER) in
I wanna know how can I write integer in php file as you can see
$status1 = \''0'\';
This code having problem, anybody please tell me what to do.
<?php
if(isset($_POST['user1'])){
$data = urldecode('%3C').'?php
$user1 = \''.$_POST['user1'].'\';
$pass1 = \''.$_POST['pass1'].'\';
$status1 = \''0'\';
$user2 = \''.$_POST['user2'].'\';
$pass2 = \''.$_POST['pass2'].'\';
$status2 = \''0'\';
$user3 = \''.$_POST['user3'].'\';
$pass3 = \''.$_POST['pass3'].'\';
$status3 = \''0'\';
$user4 = \''.$_POST['user4'].'\';
$pass4 = \''.$_POST['pass4'].'\';
$status4 = \''0'\';
$user5 = \''.$_POST['user5'].'\';
$pass5 = \''.$_POST['pass5'].'\';
$status5 = \''0'\';
$user6 = \''.$_POST['user6'].'\';
$pass6 = \''.$_POST['pass6'].'\';
$status6 = \''0'\';
$user7 = \''.$_POST['user7'].'\';
$pass7 = \''.$_POST['pass7'].'\';
$status7 = \''0'\';
$user8 = \''.$_POST['user8'].'\';
$pass8 = \''.$_POST['pass8'].'\';
$status8 = \''0'\';
$user9 = \''.$_POST['user9'].'\';
$pass9 = \''.$_POST['pass9'].'\';
$status9 = \''0'\';
$user10 = \''.$_POST['user10'].'\';
$pass10 = \''.$_POST['pass10'].'\';
$status10 = \''0'\';
?'.urldecode('%3E');
$fx=fopen('datauser.php','w');
fwrite($fx,$data);
fclose($fx);
if($fx === false) {
header("Location: ./tokensettings.php?save=err");
}
else {
header("Location: ./tokensettings.php?save=success");
}
}
?>
Thank you so much.
Here is how my form looks like.
If you still want to do it your way you need to use the \ correctly for each ' to be included in the string even those in [ ] - not saying the final string produced would actually work but it is based on your code and my best guess at your desired result
<?php
$string1=' \'\'.$_POST[\'user1\']\'\';';
$string1=$string1.'\'\'0\'\';';
echo $string1;
?>
The whole urlencoding stuff is not needed at all, your quoting and escaping is messy and incorrect. and why not simply use file_put_contents? Use HEREDOC to avoid messy escaping.
file_put_contents('datauser.php', <<<CONTENT
<?php
\$user = '{$_POST['user']}';
\$pass = '{$_POST['pass']}';
\$status = '0';
CONTENT
);
but if you really want to use files as data storage, I would encourage you to save it in a data format like xml or json instead of writing php.
// save data to file ($_POST used as example...)
file_put_contents('user.json', json_encode($_POST));
// read data
$data = json_decode(file_get_contents('user.json'));
Hoe can i get the below $_GET variables into fpdf
//User Details
$Name = $_GET['name'];
$Surname = $_GET['surname'];
$City = $_GET['city'];
$CountryCode = $_GET['countrycode'];
$Phone = $_GET['phone'];
$Email = $_GET['email'];
<?php
include('includes/fpdf.php');
$Name = $_GET['name'];
$Surname = $_GET['surname'];
$City = $_GET['city'];
$CountryCode = $_GET['countrycode'];
$Phone = $_GET['phone'];
$Email = $_GET['email'];
class PDF extends FPDF
{
// Page header
function Header()
{
I need to create a pdf after a form submission and let the user print the file.
I'm not familiar with fpdf at all but in your class methods you would do something like
$pdf = new PDF();
$pdf->someMethod($Name);
Which would pass you $Name variable into that method
include('includes/fpdf.php');
public $Name = "";
class PDF extends FPDF
{
function XYZ()
{
$this->Name = $_GET["name"];
}
}
This is the way of receiving the data in a class. But its more better if
you read the fpdf documentation, in which you can get more information
about generating the pdf.
The FPDF API seems to be an entire library of functions and features.
Writing how to use all the functions here would be a waste of time, so please find documentation of FPDF in other locations.
Here is the first link I found that appears to be fruitful:
Generating PDF files with PHP and FPDF