0

I would like to display a php page (form.php) if the user enter a value found in a database. this page is in an include an set as display none in a span tag. If the user enter a correct value i woulk like to display it. i have a try to do it, but i need help.

<?php
 if (!empty ($_POST['submit']) AND $_POST['submit'] == 'Verifier')
 {
 $numero = mysqli_real_escape_string($conn,$_POST['numero']);
 $sql = "Select numero from transaction where numero='$numero' ";
$res = mysqli_query($conn, $sql);
 if (mysqli_num_rows($res) != 0)
{
 ?>
<script type="text/javascript">
document.getElementById('trans').style.display=="block";
</script>                           
<?php
}
else
{
?>
<script type="text/javascript">
document.getElementById('trans').style.display=="none";
</script> 
<?php
}
}
?>
<form action="inscription.php" method="post"  >
<input type="text" name= "numero"   required>
<input type="submit" value="Verifier" name="Verifier" />
</form>
<span id ="trans" style="display:none" >
<? php include('form.php');  ?>
</span>

If i use the wrong method to do it your help is appreciated.

branche
  • 73
  • 8
  • instead of using js.. directly give if condition to the span which you don't wanted to display if the records aren't available.. – ameenulla0007 Jan 19 '16 at 19:05
  • Also, `document.getElementById('trans').style.display=="block";` - `==` evaulates that `document.getElementById('trans').style.display` is equal to something, it does not set the value. You want just a single `=`. – neilsimp1 Jan 19 '16 at 19:06
  • the link sent by Fred doesn't concern – branche Jan 19 '16 at 19:13
  • i happen to do it using ajax. thanks to all – branche Jan 19 '16 at 19:27
  • *"the link sent by Fred doesn't concern"* - Oh? Everything inside this `if (!empty ($_POST['submit']) AND $_POST['submit'] == 'Verifier'){...}` will NOT fire. See what you get from http://php.net/manual/en/function.error-reporting.php and you'll see what I'm talking about. – Funk Forty Niner Jan 19 '16 at 19:31
  • then this ` php include` if that's your real code, another fail. But then again, how many times I've seen posted code that isn't their real code. – Funk Forty Niner Jan 19 '16 at 19:35

0 Answers0