phpmyadmin db连接到php中的表单

时间:2017-11-17 22:15:56

标签: php html

我无法在PHPMyAdmin中将我的php页面连接到我的数据库.. 它是一个注册页面,我试图将数据插入名为admin的表中,但它无法正常工作。输出如屏幕截图所示

output screenshot

<?php

$q= mysqli_connect("localhost","root","","saramadani");
if (mysqli_connect_errno())
{
echo("Error In connection");
}
else
{
  echo("<center><h1>Database Connected</h1>");
}


$ufname=($_POST['ufname']);
$ulname=($_POST['ulname']);
$username=($_POST['username']);
$uemail=($_POST['uemail']);
$umobile=($_POST['umobile']);
$password=($_POST['password']);
$sql="INSERT INTO admin(ufname,ulname,username,uemail,umobile,password)VALUES('$ufname','$ulname','$username','$uemail','$umobile','$password')";

if(mysqli_query($q,$sql))
{echo "<center><h1>Record added successfully</h1>";}

else

{echo "error in insertion";}
mysqli_close($q);


**And here is the form part code where the post function:**

<form action="signup1.php" method="post">

          <input type="text" name="ufname" required>

          <input type="text" name="ulname" required>

          <input type="text"  name="username" required>

          <input type="email" name="uemail" required>

          <input type="phone" name="umobile" required>

          <input type="password" name="password" required>
          <button type="submit">Sign up</button>
      </form>

1 个答案:

答案 0 :(得分:2)

您正在以file:///网址访问PHP文件。 PHP不在浏览器中运行 - 它需要一个实际的Web服务器。由于您使用的是XAMPP,它将位于http://localhost/

作为旁注,phpMyAdmin与此无关。您正在使用MySQL - phpMyAdmin只是查看/管理MySQL数据库的一种(多种方式)。