跳转问题
一个注册邮件验证的程序,就是用户注册了会发封邮件到用户邮箱,然后用户点击下邮箱中的邮件,key有效则注册成功,写入注册信息,无效则跳转错误页面
在本机localhost测试没问题,到服务器上就出了问题,服务器和本机服务端版本是一样
用户点击邮件验证会跳转到如下页面
链接样式:http://www.haha.net/zhuce.php?key=21_nci34dgjs5guzopl4gi0s62puk9r0o
<?phprequire('shujulianjie.php'); //接入数据库文件date_default_timezone_set('Asia/Shanghai'); //此句用于消除时间差$iipp = $_SERVER["REMOTE_ADDR"]; //获取ip$times = date("Y-m-d H:i:s"); //取得?前??//验证key有效性和找出注册信息 $key=$_GET["key"]; $key=addslashes(trim($key)); echo $key; date_default_timezone_set('Asia/Shanghai');//此句用于消除时间差 $time=time();//当前时间戳 $time=$time-86400;//获取一天之前的时间戳 //找出是否存在或失效 $str10="select mail from zhuceyanzheng where yanzhengzi='$key' and zhuangtai='0' and shijiancuo>'$time' " ; $result10=mysql_query($str10, $con); //送出查? $row10=mysql_num_rows($result10); echo $row10; if(!$row10) {//未找到跳转到失败页面 echo'<script language="javascript" type="text/javascript">'; echo 'window.location.href="zhucejieguo.php?zt=0"; '; echo ' </script>'; exit; } else { //有则写入注册信息 echo'<script language="javascript" type="text/javascript">'; echo 'window.location.href="zhucejieguo.php?zt=1"; '; echo ' </script>';}mysql_close($con);?>
现在得到的结果是注册信息写入了,但是跳转到了window.location.href="zhucejieguo.php?zt=0,
不知道是什么原因
回复讨论(解决方案)
我感觉你为啥用时间来查找呢?你看你的SQL放到mysql控制台是否能查到数据,然后一步步打印结果排查问题。我感觉问题还是出在SQL上。
我感觉你为啥用时间来查找呢?你看你的SQL放到mysql控制台是否能查到数据,然后一步步打印结果排查问题。我感觉问题还是出在SQL上。
时间是验证key是否过期了
用了 if (!mysql_query($str10, $con))
{
die('Error: ' . mysql_error());
}
没有报错
echo $row10; 看看这个值输出是多少
echo $row10; 看看这个值输出是多少
这个输出是0,
我也觉得奇怪,因为
$str10="select mail from zhuceyanzheng where yanzhengzi='$key' and zhuangtai='0' and shijiancuo>'$time' " ;
这个语句是有符合条件的
而且输出为0,注册信息还写入了,这就是我不理解的地方,输出为0,应该不会写入注册信息才对
echo $row10; 看看这个值输出是多少
这个输出是0,
我也觉得奇怪,因为
$str10="select mail from zhuceyanzheng where yanzhengzi='$key' and zhuangtai='0' and shijiancuo>'$time' " ;
这个语句是有符合条件的
而且输出为0,注册信息还写入了,这就是我不理解的地方,输出为0,应该不会写入注册信息才对
0就说明你那个查询没查到数据啊。
这个语句在本机可以查到数据,不知道为什么到服务器上就不行,本机和服务器,数据库,脚本都是一样的
还有,结果是0,但下面的写入注册信息里面的语句确执行了
if(!$row10) {//未找到跳转到失败页面 echo'<script language="javascript" type="text/javascript">'; echo 'window.location.href="zhucejieguo.php?zt=0"; '; echo ' </script>'; exit; } else { //($row10=0,下面的语句会执行) $str3 = "update zhuceyanzheng set zhuangtai='1' where mail='$youxiang' "; $result3=mysql_query($str3,$con); }
怎么可能? var_dump($row10); 看看是什么。
怎么可能? var_dump($row10); 看看是什么。
因为是在邮箱中点击一个链接在到这个页面,这个样子的链接
链接样式:http://www.haha.net/zhuce.php?key=21_nci34dgjs5guzopl4gi0s62puk9r0o
刚刚试了,使用新标签中打开链接,就是正常的,难道是因为这种跳转链接不能在QQ邮箱中直接打开吗
那就单独执行一下你的SQL语句,看看结果吧
那就单独执行一下你的SQL语句,看看结果吧
单独执行了,有用,可以找到数据
、、、、、、、、、、、
刚刚又试了几次,现在的情况是,有时候成功,有时候失败。。。。。。实在是诡异
where yanzhengzi='$key' and zhuangtai='0' and shijiancuo>'$time' "
明????有匹配,?出完整的sql看看。
估??$time有?。
看看你的sql语句,打印sql
看看你的sql语句,打印sql
打印了,有时候会成功,有时候会失败,1是成功的,0是失败的,打印的语句如下
同样的脚本,有时候成功,有时候失败,实在很难找原因,
我的注册流程,是在邮箱中点击链接,和一般的网站一样,我现在是用QQ邮箱测试,有时候成功,有时候失败,
但是如果在新标签和新窗口打开链接,却都是成功的
而且,即使失败了,也会写入注册信息,这个明显不合理,并且,写入的IP是上海地区的ip,本人在重庆
就是说,成功写入注册信息,ip是我自己的,失败写入注册信息,ip在上海,而且是动态ip
是不是在QQ邮箱跳转的时候有什么变化
注册过程在本地localhost测试,是一点问题没有。。。。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to implement page jump after PHP form submission [Introduction] In web development, form submission is a common functional requirement. After the user fills out the form and clicks the submit button, the form data usually needs to be sent to the server for processing, and the user is redirected to another page after processing. This article will introduce how to use PHP to implement page jump after form submission. [Step 1: HTML Form] First, we need to write a page containing a form in an HTML page so that users can fill in the data that needs to be submitted.

PHP login jump value transfer method: 1. POST value transfer, use the HTML "form" form jump method to post value transfer; 2. GET transfer value, use the <a> tag to jump to xxx.php , obtain the passed value through "$_GET['id']"; 3. SESSION passes the value. Once saved in SESSION, other pages can be obtained through SESSION.

When writing a website or application, you often encounter the need to jump to a specific page. In PHP, we can achieve page jump through several methods. Below I will demonstrate three common jump methods for you, including using the header() function, using JavaScript code, and using meta tags. Using the header() function The header() function is a function used in PHP to send original HTTP header information. This function can be used in combination when implementing page jumps. Below is a

Title: Implementation method of page jump in 3 seconds: PHP Programming Guide In web development, page jump is a common operation. Generally, we use meta tags in HTML or JavaScript methods to jump to pages. However, in some specific cases, we need to perform page jumps on the server side. This article will introduce how to use PHP programming to implement a function that automatically jumps to a specified page within 3 seconds, and will also give specific code examples. The basic principle of page jump using PHP. PHP is a kind of

Methods to close the jump shopping app: 1. Turn off the jump function within the app; 2. Change browser settings; 3. Uninstall updates or reinstall the app. Detailed introduction: 1. Turn off the jump function in the app, open the shopping app, click on the product you want to buy on the homepage or search results page, and after entering the product details page, do not directly click "Buy Now" or similar buttons, but First click the "More" or "Settings" icon in the upper right corner of the page. In the pop-up menu, find "Turn off jump" or a similar option, click it, confirm to turn off the jump function, etc.

Jump statements include: 1. break statement, which is used to exit a loop or a switch statement to allow the program to continue executing the code after the loop. The syntax is "break;"; 2. continue statement is used to exit this loop and start the next one. Loop, syntax "continue;"; 3. Combined with labels to jump to the specified label statement, syntax "label + :"; 4. goto statement, used to unconditionally transfer to the specified line in the program, syntax "goto label; ... ...Tag: expression;".

In web development, we often encounter the need to hide the page address or redirect the page. Since the address in the browser address bar can be viewed and modified by the user at any time, some server-side technologies are required to truly hide or redirect the page address. Among them, PHP is a commonly used server-side scripting language that can be used to implement hidden address jumps.

Title: PHP Programming Tips: How to Jump to a Web Page within 3 Seconds In web development, we often encounter situations where we need to automatically jump to another page within a certain period of time. This article will introduce how to use PHP to implement programming techniques to jump to a page within 3 seconds, and provide specific code examples. First of all, the basic principle of page jump is realized through the Location field in the HTTP response header. By setting this field, the browser can automatically jump to the specified page. Below is a simple example demonstrating how to use P
