I am a total beginner and is trying to develop my first script for password recovery in PlayFab. I have been watching tutorials and read quite a lot but still not being able to fix my problem.
The PlayFab process I am trying to create is: Using Email Templates to Send an Account Recovery Email - PlayFab | Microsoft Docs
…and the REST API I am trying to get working is: Account Management - Reset Password - REST API (PlayFab Admin) | Microsoft Docs
However I do believe I was able to create a “working” script except I had no payload. I am now rewriting the script to clean it up etc. and most important solve my problem (which I need help with).
With the attached script I am trying to solve the problem with the token.
- When the website load I am able to extract, read and display the token
- After I pressed the button the $token = null.
This is what I am not able to solve and need some help with, which I would really appreciate.
Here is the current test script I am working on:
<!DOCTYPE HTML>
<html>
<head>
<style>
.error {color #FF0000;}
.button {
background-color: black;
border: none;
color: white;
padding: 15px 32px;
t ext-align: center:
text-decoration: none;
display: inline-block;
margin: 4px 2px;
cursor: pointer;
font-size: 15px;
}
</style>
</head>
<body>
<?php
//error_reporting(E_ALL);
error_reporting(E_NOTICE);
ini_set('display_errors', 1);
header("Content-Type: text/html");
// Define variables and null them
$url = "";
$token = "";
$actual_link = "";
$emailErr = "";
$email = "";
$pw1Err = "";
$pw2Err = "";
$token = "";
$myTest = "";
$xTest = "";
// Read actual link
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
// Extract token from url
$url_components = parse_url($actual_link);
parse_str($url_components['query'], $token);
//$myTest = $_POST['token'];
//echo $myTest;
/*
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
// CHECK EMAIL INPUT
if (empty($_POST["email"]))
{
$emailErr = "Email is required";
}
else
{
$email = test_input($_POST["email"]);
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
}
}
}
*/
// Test validity of the email address
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if (isset($_POST['submitBtn']))
{
echo "submitBtn 1 has been pressed";
echo "<br>";
echo $token['token']
}
?>
<h2>Password Recovery</h2>
<p><span class="error">*required field</span></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
E-mail:<input type="text" name="email" value="<?php echo $email;?>">
<span class="error">*<?php echo $emailErr;?></span>
<br><br>
New Password:<input type="text" name=pw1 value="";">
<span class="error">*<?php echo $pw1Err;?></span>
<br><br>
Confirm Password:<input type="text" name=pw2 value="";">
<span class="error">*<?php echo $pw2Err;?></span>
<br><br><br>
<input type="submit" class="button" name="submitBtn" value="Submit" if="myButton" />
</form>
<br><br><br>';
<h3>PRINT VARIABLES</h3>
<?php
// Print values
echo 'TOKEN: ' . $token['token'];
echo "<br>";
echo 'MYTEST: ' . $myTest[0];
echo "<br>";
echo 'FULL URL: ' . $actual_link;
echo "<br>";
echo 'EMAIL: ' . $email;
echo "<br>";
echo 'XTEST: ' . $xTest;
?>
</body>
</html>