mysql - How to display error message in view page using PHP -


i need display error message using php.i explaining code below.

addcomplain.php:

<div style="color:#f00; text-align:center;"><?php echo $error?></div> <form name="billdata" id="billdata"  enctype="multipart/form-data" method="post" onsubmit="javascript:return checkform();" action="complain.php"> </form> 

suppose have form above , when submit below file called.

complain.php:

$sql="select * medilink_complain email='".$email."'"; $selres = mysqli_query($con,$sql);  if(mysqli_num_rows($selres ) > 0)    {     $error = "email id exists!";      } 

when above error come,i need should display above form.in case not getting anything.please me resolve issue.

you don't need session.

merge code 1 file. show $error if not null, so:

<?php    $error = null;     if ($_server['request_method'] == 'post') {        $sql="select * medilink_complain email='".$email."'";        $selres = mysqli_query($con,$sql);         if(mysqli_num_rows($selres ) > 0) {            $error = "email id exists!";        }     }  ?>  <div style="color:#f00; text-align:center;"><?= (!is_null($error) ? $error : ''); ?></div>      <form name="billdata" id="billdata"  enctype="multipart/form-data" method="post" onsubmit="javascript:return checkform();" action="complain.php">      </form> </div> 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -