简体   繁体   English

成功重定向后,我想更新mysql表

[英]I want to update mysql table after successful redirection

I am trying to make a php website. 我正在尝试制作一个PHP网站。 I need help for that. 我需要帮助。 I am creating a url shortner and I need to update total views of links. 我正在创建一个URL缩短程序,我需要更新链接的总视图。 I want to UPDATE mysql db after successful redirection. 成功重定向后,我想更新mysql db。

for eg, 例如

I am visiting a link abc.in/ggl which will redirect me to google site. 我正在访问abc.in/ggl链接,该链接会将我重定向到Google网站。 Total views of the link is 20. If anyone else will go to link abc.in/ggl and it will redirect after 2 seconds to google site. 该链接的总观看次数为20。如果其他人将链接到abc.in/ggl,它将在2秒后重定向到Google网站。 If redirection is successful then my mysql db will be updated and total views of google website will be 21 in my database. 如果重定向成功,则我的mysql数据库将被更新,并且在我的数据库中Google网站的总浏览量将为21。 If redirection is not successful then my mysql db will not be updated and total views of google site will be 20. 如果重定向不成功,那么我的mysql数据库将不会更新,并且Google网站的总浏览量将为20。

my codes are these and its not working. 我的代码是这些,并且不起作用。

$a = header( "refresh:5;url=$rd" );

        if ($a)
        {
        $query="UPDATE `url` SET `view`=(`view`+1) WHERE code = 'ggl'";
        $mysql1 = mysql_query($query);
        }

$rd comes from database and in this case it is google site. $ rd来自数据库,在这种情况下,它是Google网站。

Using queue? 使用队列? You throw task in queue before you redirect user, after that worker is processing this task. 在工作人员处理此任务之后,您在重定向用户之前将任务放入队列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM