douhuo3696 2018-04-21 16:05
浏览 73
已采纳

PHP MySQL注册表不起作用,没有错误[重复]

This question already has an answer here:

I have problem with register form created in php mysql. I have form in html and php part with connection on db and insert query. I need to get input data from the form with _POST method and insert that in db. There are no errors it just wont submit it.

Here is my code:

<form action="registriraj.php" method="post" >
                <div class="wrap-input100 validate-input m-b-23" data-validate = "Username is reauired">
                    <span class="label-input100">Ime:</span>
                    <input class="input100" type="text" name="imeregistracija" placeholder="Upišite ime">
                    <span class="focus-input100" data-symbol="&#xf206;"></span>
                </div>

                <div class="wrap-input100 validate-input" data-validate="Password is required">
                    <span class="label-input100">Prezime:</span>
                    <input class="input100" type="text" name="prezimeregistracija" placeholder="Upišite prezime">
                    <span class="focus-input100" data-symbol="&#xf206;"></span>
                </div>

                <div class="wrap-input100 validate-input m-b-23" data-validate = "Username is reauired" style="margin-top: 20px;">
                    <span class="label-input100">E-mail</span>
                    <input class="input100" type="email" name="emailregistracija" placeholder="Upišite E-mail">
                    <span class="focus-input100" data-symbol="&#xf206;"></span>
                </div>

                <div class="wrap-input100 validate-input" data-validate="Password is required">
                    <span class="label-input100">Lozinka</span>
                    <input class="input100" type="password" name="passregistracija" placeholder="Upišite lozinku">
                    <span class="focus-input100" data-symbol="&#xf190;"></span>
                </div>

            <button type="submit" class="btn btn-outline " style="background-color:#ff6e00;margin-top: 25px;" name="submit">Registriraj korisnika</button>


          </form></div></center>

PHP code:

<?php
$connection = mysql_connect("localhost", "root", ""); // Establishing Connection with Server
$db = mysql_select_db("baza", $connection); // Selecting Database from Server
if(isset($_POST['submit'])){ // Fetching variables of the form which travels in URL
$imeregistracija = $_POST['imeregistracija'];
    $prezimeregistracija = $_POST['prezimeregistracija'];
    $emailregistracija = $_POST['emailregistracija'];
    $passregistracija = $_POST['passregistracija'];
if($imeregistracija !=''||$passregistracija !=''){
//Insert Query of SQL
$query = "INSERT INTO `users` (`ime`, `prezime`, `user_pass`, `user_email`) VALUES ('dva','jedan','tri','cetri')";
echo "<br/><br/><span>Data Inserted successfully...!!</span>";
mysqli_query($connection, $query);
}
else{
echo "<p>Insertion Failed <br/> Some Fields are Blank....!!</p>";
}
}
mysql_close($connection); // Closing Connection with Server
?>
</div>
  • 写回答

2条回答 默认 最新

  • dongluan1901 2018-04-21 16:13
    关注

    first check it are you connected to database.Then change $db = mysql_select_db("baza", $connection); to improved version of mysqli stmt i.e $db = mysqli_select_db($connection ,"baza"); and your code not SQL injection protected .it will help you

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决