0

How to get the data from database and echo on PHP page?


Mycode :
$emailto = $_POST["email"];
$stmt = $con->prepare("SELECT id from  enseignant where email = $emailto)");
$stmt->bind_param("s",$emailto);
$stmt->execute();
$result = $stmt->get_result();
$user = $result->fetch_assoc();

but I am getting the following error

Fatal error: Uncaught Error: Call to a member function bind_param()

Daniel
  • 1,426
  • 1
  • 11
  • 24
amine
  • 1
  • 2

1 Answers1

1

You need to use questionmark in place of the parameter you want to set with bind_param(). The following code should work

$emailto=$_POST["email"];
$stmt = $con->prepare("SELECT id from enseignant where email = ?");
$stmt->bind_param("s",$emailto);
$stmt->execute();
$result = $stmt->get_result();
$user = $result->fetch_assoc();
Loupeznik
  • 318
  • 5
  • 8