插入不是以php和mysql形式发生的

时间:2015-08-14 15:15:29

标签: javascript php mysql html5

我的数据库字段为:<?php include_once('connect_to_mysql.php'); if(isset($_POST["submit"])){ $a=mysql_real_escape_string($_POST["name"]); $b=mysql_real_escape_string($_POST["email"]); $c=mysql_real_escape_string($_POST["address"]); $d=mysql_real_escape_string($_POST["phoneno"]); $e=mysql_real_escape_string($_POST["user"]); $f=mysql_real_escape_string($_POST["pass"]); $g=mysql_real_escape_string($_POST["category"]); $res=mysql_query("insert into reg(name, email_id, address, phone_no, username, password, category, date ) values ( '$a', '$b', '$c', '$d', '$e', 'md5[$f]', '$g', now() )") or die (mysql_error() ); $id = mysql_insert_id(); } ?>

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title> Register </title>

  </head>

   <body>

       <div id="heading12"><?php //include_once("header.html") ?></div>
           <br /><br /><br /><br /><br /><br /><br />
       <div id="mainWrapper" style="background-color:#ECEEFB">

       <div align="center" id="pageContent" style="background-image:url(back3.png); width:1000px;"><br /><br /><br />
       <div align="center" style="color:#000000;">
       <h2 style="font-size:36px">Please Fill Your all Details to Register</h2>
       <br /><br />
       <form id="form" name="form" method="post" action="register.php">
         <h2 style="padding-right:200px;"> Name:</h2>
         <input name="name" type="text" id="name" size="40" style="height:30px; font-size:20px " required placeholder="Enter NAME"/>
           <br /><br />

        <h2 style="padding-right:200px;">Email Address:</h2>
        <input name="email" type="text" id="email" size="40" style="height:30px; font-size:20px " required placeholder="Enter Email Address"/>
           <br /><br />

        <h2 style="padding-right:200px;">Address</h2>
        <textarea name="address" id="address" cols="44" rows="6" style="font-size:19px " required placeholder="Enter Address"></textarea>
   <br /><br />

        <h2 style="padding-right:200px;">Phone No.</h2>
        <input name="phoneno" type="text" id="phoneno" size="40" style="height:30px; font-size:20px" required placeholder="Enter Phone No."/>
        <br /><br />

        <h2 style="padding-right:200px;">User Name:</h2>
        <input name="user" type="text" id="user" size="40" style="height:30px; font-size:20px" required placeholder="Enter UserName"/>
        <br /><br />

        <h2 style="padding-right:210px;">Password:</h2>
        <input name="pass" type="password" id="pass" size="40" style="height:30px; font-size:20px" required placeholder="Enter Password"/>
        <br /> <br />

        <h2 style="padding-right:250px;">Category:</h2> 
        <select name="category" id="category" style="height:30px; font-size:20px; padding-right:290px;" required placeholder="Enter The Value" >
           <option value="none">Choose Any</option>
           <option value="product buyer">Product Buyer</option>
           <option value="product seller">Product Seller</option>
       </select>
       <br /> <br />

       <img style="padding-right:280px;" src="generate.php"><br /><br />
       <input type="text" name="secure" size="10" required placeholder="Enter The Value" style="padding-right:290px; height:30px; font-size:20px">
       <br />  <br /> <br />
       <input type="submit" name="log" id="log" value="Register"  style="padding-right:40px; font-size:20px" />

    </form>
    <p>&nbsp; </p>
 </div>
   <br />
  <br />
   <br />
    </div>

    </div>
      </body>
    </html>

使用提交按钮时没有报告错误,但发现数据未插入数据库。我不知道是什么原因造成的。

$browsersArray["Firefox"][] = $result_browser_pageview;

3 个答案:

答案 0 :(得分:2)

你没有任何名称为“提交”。 $ _POST ['submit']永远不会设置,你的if函数永远不会运行。

答案 1 :(得分:1)

您的情况正在寻找$ _POST [&#39;提交&#39;]

$ _ POST [&#39;提交&#39;]不存在

用$ _POST替换$ _POST [&#39;提交&#39;]并获取您的所有数据

Php由于某种原因消除了mysql,使用mysqli进行数据库连接和查询

答案 2 :(得分:1)

请查看提交按钮的HTML - &gt; 输入类型=“提交”

在您的PHP代码中,您正在检查是否存在名为“submit”的提交按钮,但实际上,提交按钮的名称是“log”

if(isset($ _ POST [“submit”]))需要更改为if(isset($ _ POST [“log”]))

这就是全部! :)