This is the code i am working on
if(isset($_POST['generate'])) {
$article_id = $_POST['generate']['id']; //escape string
$domain = $_POST['generate']['domain']; //escape string
$userid = $_POST['generate']['uid']; //escape string
if(!$db->getRow("SELECT * FROM `".PREFIX."user_stats` WHERE `article_id` = ?i AND `domain` = ?s AND `userid` = ?i", $article_id, $domain, $userid)) {
$key = randomIDGenerator();
$http = "http://";
$tracking = array(
"userid" => $userid,
"username" => $user->data->username,
"article_id" => $article_id,
"key" => $key,
"domain" => $domain,
"created" => $time
);
if(($db->query("INSERT INTO `".PREFIX."user_stats` SET ?u", $tracking)) && ($id = $db->insertId()) && ($db->query("UPDATE `".PREFIX."articles` SET `shared` = `shared` + ?i WHERE `article_id` = ?i", 1, $article_id))) {
$tracking_url = $domain.$key;
echo json_encode(array("status" => "Success", "url" => $http.$tracking_url));
} else {
echo json_encode(array("status" => "Error", "msj" => "Internal error. Please refresh the page and try again."));
}
} else {
echo json_encode(array("status" => "Error", "msj" => $domain.$key." Resharing."));
}
}
It generate url for user and then show it, and if the url is already generated for same article then this is where the last "else" come
what I want is if even the url is generated before, it still show old generated url with resharing text
I tried $domain.$key." Resharing."
which shows the domain but not the key
and also I tried
echo json_encode(array("status" => "Success", "url" => $http.$tracking_url));
with no luck
I don't know how good i explained my problem please let me know if i need to explain more.