首页 >社区问答列表 >请问提交表单是空白是哪里出错了

请问提交表单是空白是哪里出错了

<?php

if(trim($_POST['password']) != trim($_POST['repassword'])){

exit ("两次使用的密码不一致,请返回上一页");

}

$username = trim($_POST['username']);

$password = md5(trim($_POST['password']));

$conn = mysqli_connect('localhost','root','root','informationtest','3306');

if(mysqli_error($conn)){

mysqli_error($conn);

exit;

}

mysqli_select_db($conn,'my_my');

mysqli_set_charset($conn,'utf8');

insert into informationtest (id,name,password,) value('','$username','$password');

?>


  • dabour
  • dabour    2017-12-07 15:58:352楼

    你是直接访问了那个文件,而不是通过服务器访问的

    +1添加回复

  • 回复

    是的,谢谢我解决了

       作者 · 2017-12-09 18:50:46
    回复
  • 路过
  • 路过    2017-12-05 08:24:071楼

    那你要看看html 是不是没有name

    +0添加回复

  • 回复

    有name,后来我发现除了火狐,其他浏览器是直接显示php代码

       作者 · 2017-12-05 18:24:57
    回复

    &lt;html&gt; &lt;body&gt; &lt;form action=&quot;connect.php&quot; method=&quot;POST&quot;&gt; &lt;table border=&quot;1&quot; style=&quot;margin:100px auto&quot;&gt; &lt;tr&gt; &lt;td&gt;用户名&lt;/td&gt; &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;username&quot; /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;密码&lt;/td&gt; &lt;td&gt;&lt;input type=&quot;password&quot; name=&quot;password&quot; /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan=2 align = center&gt;&lt;input type=&quot;submit&quot; value=&quot;注册&quot; name=&quot;submit&quot; /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; //以上是html代码

       作者 · 2017-12-05 18:27:51
    回复

    搞定了,百度的:直接localhost访问网站目录 假设你有一个静态页index.html,将静态页拷到你的网站目录,然后是用localhost/index.html访问

       作者 · 2017-12-05 19:23:57
    回复

    我用Notepad++打开浏览器的,显示的地址是file:///D:/phpStudy/PHPTutorial/WWW/login.html这样的,不是localhost/login.html,所以导致html跳转直接显示php代码。虽然解决了,但是原理还是懵逼。

       作者 · 2017-12-05 19:26:11
    回复