表单未在服务器上传递 [英] Form Not Being Passed On Server

查看:124
本文介绍了表单未在服务器上传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站上有一张注册表格,该表格将输入内容通过JQuery Post传递到PHP文件中.在运行PHP 5.2的本地主机上,所有这些都可以正常运行,但是当我将其上传到服务器(5.4)时,我遇到了无法处理表单的问题.

I have a registration form on my website which passes the inputs through JQuery Post and into a PHP file. This all works fine on my localhost which runs PHP 5.2, but when I upload it to my server (5.4) I'm getting problems with the form not being processed.

这是我正在使用的代码:

Here is the code I'm using:

$time = time();
$id= time().'-'.mt_rand(100000000, 999999999);
$type= mysqli_real_escape_string($con, $_REQUEST["type"]);
$subtype= mysqli_real_escape_string($con, $_REQUEST["subtype"]);
$name= mysqli_real_escape_string($con, $_REQUEST["name"]);
$name = ucwords(strtolower($name));
$email= mysqli_real_escape_string($con, $_REQUEST["email"]);
$relative= mysqli_real_escape_string($con, $_REQUEST["relative"]);
$relative = ucwords(strtolower($relative));
$summary= mysqli_real_escape_string($con, $_REQUEST["bio"]);
$postcode= mysqli_real_escape_string($con, $_REQUEST["postcode"]);
$sendpassword= mysqli_real_escape_string($con, $_REQUEST["password"]);
$password= md5(mysqli_real_escape_string($con, $_REQUEST["password"]));
$hash = md5( rand(0,1000) );

推荐答案

首先,查看您的代码,您正在使用mysqli_real_escape_string()进行输入清理.这不是一个好主意,因为如果您没有与MySQL数据库的活动mysqli连接,它将无法运行并引发错误.

Firstly, looking at your code, you are using mysqli_real_escape_string() to do your input sanitization. This is not a great idea, as it will fail to run and throw an error if you do not have an active mysqli connection to a MySQL database.

第二,看看服务器上的PHP错误日志.那应该给你一个提示,指出出了什么问题.如果您没有错误日志设置,或者不知道它在哪里,那么请查看php.ini配置文件(在Linux上,该文件通常位于/etc/php/apache2/php.ini中-这样),然后搜索如下所示的行:

Secondly, take a look at the PHP error log on your server. That should give you a clue as to what is going wrong. If you do not have an error log setup, or don't know where it is, then take a look in the php.ini configuration file (on linux this is located normally at /etc/php/apache2/php.ini - something like that) and search for the line that looks like:

error_log = <something>

如果该行前面有分号(;),则将其删除.此行/指令设置PHP写入错误消息的位置.您可以将其设置为任何所需的值,然后记住重新启动Web服务器以应用更改.

If there is a semicolon (;) in front of that line, then remove it. This line/directive sets the location to which PHP writes error messages. You can set this to whatever you want, and then remember to restart your webserver to apply the change.

然后尝试再次运行PHP代码,然后在您指定为error_log的文件中查找问题所在.我的猜测是它与mysqli_real_escape_string()有关.

Then try running your PHP code again, and then look in the file you specified as the error_log to see what is going wrong. My guess would be that it has to do with the mysqli_real_escape_string().

我希望这会有所帮助.

关于, 拉尔夫

这篇关于表单未在服务器上传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆