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 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记