0

i want to change value of 2nd input after submitting the value of first input but it's not happening. i want to print email in 2nd input value

<?php
$db = mysqli_connect('localhost','root','root','rahul');
if(isset($_POST['submit']))
{
 $email = $_POST['email'];
 $sql = mysqli_query($db,"select * from register where email='$email'");
 
 if(mysqli_fetch_array($sql)==true)
 {
  echo '<input type="text" name="question" value="$email">'; /* 2nd input */
 }
 else
 {
  echo "no";
 }
}
?>

<center><br><br>
<form action="" method="post" >
<input type="text" name="email"><br><br> /* first input*/
<input type="submit" name="submit">
</form>
Raa Hul
  • 63
  • 1
  • 1
  • 7

1 Answers1

0

echo '<input type="text" name="question" value="$email">'; : This will not work because you have to use double quotes to echo php var in it

Like this :

echo "<input type='text' name='question' value='$email'>";

or like this :

echo "<input type='text' name='question' value='".$email."'>";
Vincent G
  • 8,547
  • 1
  • 18
  • 36