I want to get Date Time from specified Username and compare to todays date. I'm using a database.
$con = mysqli_connect("server", "name", "pass", "db");
if(!$con) {
die("noconn");
}
$HWID = "";
if(isset($_POST['HWID']) && !empty($_POST['HWID'])) {
$HWID = mysqli_real_escape_string($con, $_POST['HWID']);
$HWID = ($HWID);
}
elseif(isset($_GET['HWID']) && !empty($_GET['HWID'])) {
$HWID = mysqli_real_escape_string($con, $_GET['HWID']);
$HWID = ($HWID);
} else {
die("nodata");
}
$rows= "";
if(isset($_GET['Expire_Date'])){
$id=$_GET['Expire_Date'];
$sql="SELECT HWID FROM users WHERE Expire_Date='$id'";
$result=mysql_query($sql);
$rows=mysql_fetch_array($result);
}
if (strtotime((new DateTime())->format("Y-m-d H:i:s")) > strtotime($rows)) {
die("valid");
} else {
die("invalid");
}
The code works together with C#
dataToSend["HWID"] = HWID();
string GetData = Encoding.UTF8.GetString(wc.UploadValues(@"http://127.0.0.1/test.php", dataToSend));
if (GetData == "valid")
{
MessageBox.Show("date is valid", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (GetData == "invalid")
{
MessageBox.Show("date is not valid", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Let's say HWID (Hardware ID) is an username 18585B53C213CA86DE91BE1E2772D66C6EC3F32F in a database and there's a date specified 2021-07-01. So when the date will run out, it will tell invalid, otherwise if it's not out, it'll tell valid. Every time I try this code it gives me valid. I'm not sure if I specified the username correctly or didn't compare correctly.