doulu0266 2015-03-10 19:33
浏览 268

如何将html表单连接到数据库sql

im to connect a form to a database but the php is giving problems any advice to help my script

                 <?php
              $connection = mysql_connect("localhost", "root", "");
               $db = mysql_select_db("hot_data", $connection);


            if(isset($_POST['submit']))
            {


                   $userid=_$POST['userid'];
                    $first_name=$_POST['fname'];
               $last_name=$_POST['lname'];
               $livingadress=$_POST['ldress'];
                 $telephone=$_POST['phone'];

                  if($userid !=''||$telephone !=''){

//Insert Query of SQL
                    $query = mysql_query("INSERT INTO personal_data(userid,first_name,last_name,living_address,telephone)


                   VALUES('$userid','$first_name','$last_name','$livingaddress','$telephone')");

              echo "<br/><br/><span>Data Inserted successfully...!!</span>";
              }
            else{
                 echo "<p>Insertion Failed <br/> Some Fields are Blank....!! </p>";
                        }
                     }
                           mysql_close($connection);
                  ?>
  • 写回答

2条回答

  • dpbvpgvrhwxen3222 2015-03-10 19:39
    关注

    You have an error on this line -

    $userid=_$POST['userid'];
    

    Should be this -

    $userid=$_POST['userid']; // $_POST variable was improperly written
    
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?