Hi All - I have a form and I want the two places in which the enquirer types their email adress in (Field emailAddress and email2) to check that the email address values are the same and send the form - if not the same just say some kind of error message eg your email address does not match... blah

Im struggling and have tried and failed, it may just be that I dont know at what point to insert a compare type php string. All suggestions will be most appreciated.

<?php

if(isset($_POST['name']))
{
	$to  = 'me@adomain.com';
	// subject
	$subject = 'Website enquiry';
	// message
	$message = '
	<html>
	<head>
	  <title>Website Enquiry</title>
	</head>
	<body>
	  <table>
		<tr>
		  <td>Name : </td><td>&nbsp;&nbsp;'.$_POST['name'].'</td>
		</tr>
		<tr>
		<td>Company Name : </td><td>&nbsp;&nbsp;'.$_POST['coName'].'</td>
		</tr>
		<tr>
		  <td>Email Address : </td><td>&nbsp;&nbsp;'.$_POST['emailAddress'].'</td>
		</tr>
		<tr>
		  <td>Confirm Email address : </td><td>&nbsp;&nbsp;'.$_POST['email2'].'</td>
		</tr>
		<tr>
		<tr>
		  <td>Contact Tel No : </td><td>&nbsp;&nbsp;'.$_POST['contactNo'].'</td>
		</tr>
		<td>How you found us : </td><td>&nbsp;&nbsp;'.$_POST['findUs'].'</td>
		</tr>
		<tr>
		  <td>Message : </td><td>&nbsp;&nbsp;'.$_POST['message'].'</td>
		</tr>
		
	  </table>
	</body>
	</html>
	';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '. $_POST['emailAddress'] . "\r\n";


// Mail it
@mail($to, $subject, $message, $headers);
//header("Location:index.html");
?>
<script type='text/javascript'>
alert("Thank you for your details. We will respond to your enquiry promptly.");
window.location.href="Contact.html";
</script>
<?php

}
?>

I have made some mods to your code, that should do it.

<?php

if (isset($_POST['name'])) {
    /** Add the check here! **/
    if ($_POST['emailAddress'] != $_POST['email2']) {
        //the email addresses are not the same, do something
        echo "E-mail mismatch";
        //you can also add html codes here
    } else {
        $to = 'me@adomain.com';
        // subject
        $subject = 'Website enquiry';
        // message
        $message = '
    <html>
    <head>
      <title>Website Enquiry</title>
    </head>
    <body>
      <table>
        <tr>
          <td>Name : </td><td>&nbsp;&nbsp;' . $_POST['name'] . '</td>
        </tr>
        <tr>
        <td>Company Name : </td><td>&nbsp;&nbsp;' . $_POST['coName'] . '</td>
        </tr>
        <tr>
          <td>Email Address : </td><td>&nbsp;&nbsp;' . $_POST['emailAddress'] . '</td>
        </tr>
        <tr>
          <td>Confirm Email address : </td><td>&nbsp;&nbsp;' . $_POST['email2'] .
            '</td>
        </tr>
        <tr>
        <tr>
          <td>Contact Tel No : </td><td>&nbsp;&nbsp;' . $_POST['contactNo'] . '</td>
        </tr>
        <td>How you found us : </td><td>&nbsp;&nbsp;' . $_POST['findUs'] . '</td>
        </tr>
        <tr>
          <td>Message : </td><td>&nbsp;&nbsp;' . $_POST['message'] . '</td>
        </tr>

      </table>
    </body>
    </html>
    ';

        // To send HTML mail, the Content-type header must be set
        $headers = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        $headers .= 'From: ' . $_POST['emailAddress'] . "\r\n";


        // Mail it
        @mail($to, $subject, $message, $headers);
        //I have moved the html codes into this block of else

?>
<script type='text/javascript'>
alert("Thank you for your details. We will respond to your enquiry promptly.");
window.location.href="Contact.html";
</script>
<?php
    }
}
?>

I have made some mods to your code, that should do it.

<?php

if (isset($_POST['name'])) {
    /** Add the check here! **/
    if ($_POST['emailAddress'] != $_POST['email2']) {
        //the email addresses are not the same, do something
        echo "E-mail mismatch";
        //you can also add html codes here
    } else {
        $to = 'me@adomain.com';
        // subject
        $subject = 'Website enquiry';
        // message
        $message = '
	<html>
	<head>
	  <title>Website Enquiry</title>
	</head>
	<body>
	  <table>
		<tr>
		  <td>Name : </td><td>&nbsp;&nbsp;' . $_POST['name'] . '</td>
		</tr>
		<tr>
		<td>Company Name : </td><td>&nbsp;&nbsp;' . $_POST['coName'] . '</td>
		</tr>
		<tr>
		  <td>Email Address : </td><td>&nbsp;&nbsp;' . $_POST['emailAddress'] . '</td>
		</tr>
		<tr>
		  <td>Confirm Email address : </td><td>&nbsp;&nbsp;' . $_POST['email2'] .
            '</td>
		</tr>
		<tr>
		<tr>
		  <td>Contact Tel No : </td><td>&nbsp;&nbsp;' . $_POST['contactNo'] . '</td>
		</tr>
		<td>How you found us : </td><td>&nbsp;&nbsp;' . $_POST['findUs'] . '</td>
		</tr>
		<tr>
		  <td>Message : </td><td>&nbsp;&nbsp;' . $_POST['message'] . '</td>
		</tr>
		
	  </table>
	</body>
	</html>
	';

        // To send HTML mail, the Content-type header must be set
        $headers = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        $headers .= 'From: ' . $_POST['emailAddress'] . "\r\n";


        // Mail it
        @mail($to, $subject, $message, $headers);
        //I have moved the html codes into this block of else

?>
<script type='text/javascript'>
alert("Thank you for your details. We will respond to your enquiry promptly.");
window.location.href="Contact.html";
</script>
<?php
    }
}
?>

i think you should check the email use javascript

<SCRIPT LANGUAGE=javascript RUNAT=Server>
function isEmail(strEmail) {
if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
return true;
else
alert("oh");
}
</SCRIPT>
<?php
function showdata($data,$count,$edit_hobbies,$edit_education,$dob,$ErrMsg,$Err){
//  echo "<pre>";
//  print_r($Err);
?>
<html>
<head>
<title>Registration Form</title>
<script src="assets/js/jquery.min.js"></script>
<style type="text/css">
body{
text-align:center;
}
span{
color:red;
}
</style>
<script type="text/javascript">
function validate(){
    var val_fname=/^[a-zA-Z]+$/;
    var val_lname=/^[a-zA-Z]+$/;
    var val_email=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    var val_mobile=/^[1-9]{1}[0-9]{9}$/;
    var val_address=/^[0-9a-zA-Z]+$/;
    var val_pincode=/^[0-9]+$/;

    var fname=document.form.fname.value;
    var lname=document.form.lname.value;    
    var dob=document.form.dob.value;
    var gender=document.form.gender.value;
    var hobbies=document.form.hobbies.value;
    var education=document.form.education.value;
    var email=document.form.email.value;
    var mobile=document.form.mobile.value;
    var address=document.form.address.value;
    var houseno=document.form.houseno.value;
    var country=document.form.country.value;
    var state=document.form.state.value;
    var pincode=document.form.pincode.value;
    var file=document.form.file.value;
    var tc=document.form.tc.value;
    var hidden=document.form.hidden.value;

    if(fname == 0){
        alert("Enter First Name");
        return false;
    }else if(lname == 0){
         alert("Enter Last Name");
         return false;
     }else if(form.dob.value == '-1'){
         alert("Select Date of Birth");
         return false;
     }else if(gender == 0){
         alert("Select Gender");
         return false;
     }else if(form.hobbies[0].checked == false && form.hobbies[1].checked == false && form.hobbies[2].checked == false){
         alert("Select Hobbies");
         return false;
     }else if(form.hobbies[0].checked == true && form.hobbies[1].checked == false && form.hobbies[2].checked == false){
         alert("Select Minimum Two Hobbies");
         return false;
     }else if(form.hobbies[0].checked == false && form.hobbies[1].checked == true && form.hobbies[2].checked == false){
         alert("Select Minimum Two Hobbies");
         return false;
     }else if(form.hobbies[0].checked == false && form.hobbies[1].checked == false && form.hobbies[2].checked == true){
         alert("Select Minimum Two Hobbies");
         return false;
     }else if(education == 0){
         alert("Select Education");
         return false;
     }else if(form.education[0].selected == false){
         alert("Select Correct Education Details");
         return false;
     }else if(form.education[0].selected == true && form.education[1].selected == false && form.education[2].selected == false){
         alert("Select Minimum Two Education Details");
         return false;
     }else if(email == 0){
         alert("Enter Email id");
         return false;
     }else if(mobile == 0){
         alert("Enter Mobile Number");
         return false;
     }else if(address == 0){
         alert("Enter Address");
         return false;
     }else if(houseno == 0){
         alert("Enter House Number");
         return false;
     }else if(country == -1){
         alert("Select Country");
         return false;
     }else if(state == -1){
         alert("Select State");
         return false;
     }else if(pincode == 0){
         alert("Enter pincode");
         return false;
     }else if(file == 0 && hidden === undefined){
         alert("Select File");
         return false;
     }else if(form.tc.checked == false){
         alert("Select Terms and Conditions");
         return false;
     }

    if(!val_fname.test(fname)){
        alert("Invalid First Name");
        return false;
    }
    if(!val_lname.test(lname)){
        alert("Invalid Last Name");
        return false;
    }
    if(!val_email.test(email)){
        alert("Invalid Email Id");
        return false;
    }
    if(!val_mobile.test(mobile)){
        alert("Inavali Mobile Number");
        return false;
    }
    if(!val_address.test(address)){
        alert("Ivalid Address");
        return false;
    }
    if(!val_pincode.test(pincode)){
        alert("Invali Pincode");
        return false;
    }
}
function validatefname(fname){
    if(/^[a-zA-Z]+$/.test(fname.value) == false){
        alert("Ivalid First Name");
        return false;
    }
}
function validatelname(lname){
    if(/^[a-zA-Z]+$/.test(lname.value) == false){
        alert("Ivalid Last Name");
        return false;
    }
}
function validateemail(email){
    if (/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(email.value) == false) {
        alert("Invalid Email Address");
        return false;
    }
}
function validatemobile(mobile){
    if(/^[1-9]{1}[0-9]{9}$/.test(mobile.value) == false){
        alert("Invalid Mobile Number & Maximum Length is 10 Numbers");
        return false;
    }
}
function validatelandline(landline){
    if(/\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/.test(landline.value) == false){
        alert("Invalid Landline Number & Maximum Length is 11 Numbers");
        return false;
    }
}
function validateaddress(address){
    if(/^[0-9a-zA-Z]+$/.test(address.value) == false){
    alert("Invalid Address");
    return false;
    }
}
// function validatehouseno(houseno){
//  if(/^[0-9a-zA-Z]+$/.test(houseno.value) == false){
//  alert("Invalid House Number");
//  return false;
//  }
// }
function validatepincode(pincode){
    if(/^[0-9]+$/.test(pincode.value) == false){
        alert("Invalid Pincode");
        return false;
    }
}
function validatestreet(street){
    if(/^[a-zA-Z]+$/.test(street.value) == false){
        alert("Invalid Street");
        return false;
    }
}
function validatelocation(location){
    if(/^[a-zA-Z]+$/.test(location.value) == false){
        alert("Invalid Location");
        return false;
    }
}
function update(value){
    if(value!='-1'){
    $.ajax({
        type:"POST",
        url:"join123.php",
        datatype:"json",
        data:{country:value},
        success: function(result) {
        //alert(result)
        var text="";
        text +="<option value='-1'>Select</option>"
        obj = JSON.parse(result);
        for(var i=0;i<obj.length;i++){
          text += "<option value='"+ obj[i].state +"'>"+ obj[i].state + "</option>";
        }   
        document.getElementById("state").innerHTML=text;
        }
     });
    }else{
        document.getElementById("state").innerHTML='<option value="-1">Select</option>';
    }
}
</script>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" onsubmit="return validate();" name="form" class="form-horizontal">
<div class="col-md-3 col-md-offset-4">
<span><?php echo $ErrMsg; ?></span><br>
<span><?php echo $Err; ?></span><br>
<label>*First Name:</label>
<input type="text" name="fname" class="form-control" id="fname" value="<?php echo $count['fname']; ?>" onchange="validatefname(this);" placeholder="Enter First Name"><br><br>
<label>*Last Name:</label>
<input type="text" name="lname" class="form-control" id="lname" value="<?php echo $count['lname']; ?>"  onchange="validatelname(this);" placeholder="Enter Last Name"><br><br>
<label>*DOB:</label>
<select name="dob[]">
<option value="-1">DD</option>
<?php 
for($i=1;$i<=31;$i++){
    $var='';
    if ($dob[0] == $i){
        $var="selected";
    }
    echo "<option value='$i'$var>$i</option>";
}
?>
</select>
<select name="dob[]">
<option value="-1">MM</option>
<?php 
for($i=1;$i<=12;$i++){
    $var='';
    if ($dob[1] == $i){
        $var= "selected";
    }
    echo "<option value='$i'$var >$i</option>" ;
}
?>
</select>
<select name="dob[]" id="dob">
<option value="-1">YYYY</option>
<?php 
for($i=1980;$i<=2017;$i++){
    $var='';
    if ($dob[2] == $i){
        $var= "selected";
    }
    echo "<option value='$i' $var>$i</option>" ;
}
?>
</select><br><br>
<label>*Gender:</label>
<input type="radio" name="gender" id="gender" value="male" <?php if ($count['gender']=='male'){echo "checked";} ?>>Male
<input type="radio" name="gender" id="gender" value="female" <?php if ($count['gender']=='female'){echo "checked";} ?>>Female
<input type="radio" name="gender" id="gender" value="other" <?php if ($count['gender']=='other'){echo "checked";} ?>>Other<br><br>
<label>*Hobbies:</label>
<input type="checkbox" name="hobbies[]" id="hobbies" value="playing cricket" <?php if (in_array('playing cricket', $edit_hobbies)){echo "checked";} ?>><label>Playing Cricket</label>
<input type="checkbox" name="hobbies[]" id="hobbies" value="reading books" <?php if (in_array('reading books', $edit_hobbies)){echo "checked";} ?>><label>Reading Books</label><br>
<input type="checkbox" name="hobbies[]" id="hobbies" value="watching tv" <?php if (in_array('watching tv', $edit_hobbies)){echo "checked";} ?>><label>Watching TV</label><br><br>
<label>*Education:</label>
<select class="selectpicker" id="education" name="education[]" onchange="validateeducation()" multiple >
<option value="SSC" <?php if (in_array('SSC', $edit_education)){echo "selected";} ?>>SSC</option>
<option value="inter" <?php if (in_array('inter', $edit_education)){echo "selected";} ?>>Inter</option>
<option value="diploma" <?php if (in_array('diploma', $edit_education)){echo "selected";} ?>>Diploma</option>
<option value="b.tech" <?php if (in_array('b.tech', $edit_education)){echo "selected";} ?>>B.Tech</option>
<option value="BE" <?php if (in_array('BE', $edit_education)){echo "selected";} ?>>BE</option>
<option value="m.tech" <?php if (in_array('m.tech', $edit_education)){echo "selected";} ?>>M.Tech</option>
<option value="mba" <?php if (in_array('mba', $edit_education)){echo "selected";} ?>>MBA</option>
<option value="mca" <?php if (in_array('mca', $edit_education)){echo "selected";} ?>>MCA</option>
</select><br><br>
<label>*Email:</label>
<input type="text" name="email" class="form-control" id="email" value="<?php echo $count['email']; ?>"  onchange="validateemail(this)" placeholder="Enter Email Id"><br><br>
<label>*Mobile:</label>
<input type="text" name="mobile" class="form-control" id="mobile" value="<?php echo $count['mobile']; ?>"  onchange="validatemobile(this)" placeholder="Enter Mobile Number"><br><br>
<label>Land Line:</label>
<input type="text" name="landline" class="form-control" id="landline" value="<?php echo $count['landline']; ?>"  onchange="validatelandline(this)" placeholder="Enter LandLine Number"><br><br>
<label>*Address:</label>
<input type="text" name="address" class="form-control" id="address" value="<?php echo $count['address']; ?>"  onchange="validateaddress(this)" placeholder="Enter Address"><br><br>
<label>*House.No:</label>
<input type="text" name="houseno" class="form-control" id="houseno" value="<?php echo $count['houseno']; ?>" onchange="validatehouseno(this)" placeholder="Enter House Number"><br><br>
<label>Street:</label>
<input type="text" name="street" class="form-control" id="street" value="<?php echo $count['street']; ?>" onchange="validatestreet(this)" placeholder="Enter Street Name"><br><br>
<label>Location:</label>
<input type="text" name="location" class="form-control" id="location" value="<?php echo $count['location']; ?>" onchange="validatelocation(this)" placeholder="Enter Location"><br><br>
<label>*Country:</label>
<select name="country" id="country" onchange="update(this.value)">
<option value="-1">Select</option>
<option id="1" value="1"<?php if ($count['country'] == 1){echo "selected";} ?>>INDIA</option>
<option id="2" value="2"<?php if ($count['country'] == 2){echo "selected";} ?>>JAPAN</option>
<option id="3" value="3"<?php if ($count['country'] == 3){echo "selected";} ?>>USA</option>
<option id="4" value="4"<?php if ($count['country'] == 4){echo "selected";} ?>>UK</option>
</select><br><br>
<label>*State</label>
<select name="state" id="state">
<option value="-1">Select</option>
<?php
for ($i=0;$i<count($data);$i++){
?>
<option value="<?php echo $data[$i]['state_id']; echo $count['state'];?>"<?php if (in_array($i, $count)){echo "selected";}?>><?php echo $data[$i]['state'] ?></option>
<?php 
}
?>
</select><br><br>
<label>*Pincode</label>
<input type="text" name="pincode" class="form-control" id="pincode" value="<?php echo $count['pincode']; ?>" onchange="validatepincode(this)" placeholder="Enter Pincode"><br><br>
<label>*File</label>
<input type="file" name="file" class="form-control" value="-1" id="file"><br><br>
<?php 
if ($_REQUEST['edit']>0){
?>
<input type="hidden" name="hidden" value=<?php echo $count['file']; ?> id="hidden">
<?php 
if (file_exists($count['file'])>0){
?>
<img src="<?php echo $count['file']; ?>" height="40" width="40" id="img">
<?php
}
}
?>
<input type="checkbox" name="tc[]" id="tc" value="Terms and Conditions">Terms and Conditions
<input type="submit" name="submit" id="sub"  class="btn btn-primary" onchange="validatesubmit(this)" value="Submit"><br><br>
</div>
</form>
<table border="1" cellspacing="0" cellpadding="5">
<thead>
<tr>
<th align="center">S.No</th>
<th align="center">First Name</th>
<th align="center">Last Name</th>
<th align="center">DOB</th>
<th align="center">Gender</th>
<th align="center">Hobbies</th>
<th align="center">Education</th>
<th align="center">Email</th>
<th align="center">Mobile</th>
<th align="center">Land Line</th>
<th align="center">Address</th>
<th align="center">House.No</th>
<th align="center">Street</th>
<th align="center">Location</th>
<th align="center">Country</th>
<th align="center">State</th>
<th align="center">Pincode</th>
<th align="center">File</th>
<th align="center">Edit</th>
<th align="center">Delete</th>
</tr>
</thead>
<tbody>
<?php 
$i=1;
foreach ($data as $v){
    $hobbiesAry=array();
    $hobbiesAry=explode(',',$v['hobbies']);
    $educationAry=array();
    $educationAry=explode(",", $v['education']);

?>
<tr>
<td align="center"><?php echo $i; ?></td>
<td align="center"><?php echo $v['fname']; ?></td>
<td align="center"><?php echo $v['lname']; ?></td>
<td align="center"><?php echo $v['dob']; ?></td>
<td align="center"><?php echo $v['gender']; ?></td>
<td align="left">
<?php 
for ($h=0;$h<count($hobbiesAry);$h++){
?>
<ul><li><?php echo $hobbiesAry[$h];?></li></ul>
<?php   
}
?>
</td>
<td align="left">
<?php 
for ($c=0;$c<count($educationAry);$c++){
?>
<ul><li><?php echo $educationAry[$c];?></li></ul>
<?php 
}
?>
</td>
<td align="center"><?php echo $v['email']; ?></td>
<td align="center"><?php echo $v['mobile']; ?></td>
<td align="center"><?php echo $v['landline']; ?></td>
<td align="center"><?php echo $v['address']; ?></td>
<td align="center"><?php echo $v['houseno']; ?></td>
<td align="center"><?php echo $v['street']; ?></td>
<td align="center"><?php echo $v['location']; ?></td>
<td align="center"><?php echo $v['country']; ?></td>
<td align="center"><?php echo $v['state']; ?></td>
<td align="center"><?php echo $v['pincode'];?></td>
<td align="center"><img src="<?php echo $v['file']?>" height="50" width="50"></td>
<td align="center"><a href="registrationform.php?edit=<?php echo $v['id']; ?>">Edit</a></td>
<td align="center"><a href="registrationform.php?delete=<?php echo $v['id']; ?>">Delete</a></td>
</tr>
<?php
$i++;
}
?>
</tbody>
</table>
<?php 
}
?>
</body>
</html>
<?php
include_once 'registrationDBConnect.php';
include_once 'registration.template.php';
$conn=connectdatabase();
$ErrMsg="";
$Err="";
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
    if ($_POST['fname'] == '' || $_POST['lname'] == '' || $_POST['dob'][0] == '-1' || $_POST['dob'][1] == '-1' || $_POST['dob'][2] == '-1' || $_POST['gender'] == '' || $_POST['hobbies'] == '' || $_POST['education'] == '' || $_POST['email'] == '' || $_POST['mobile'] == '' || $_POST['address'] == '' ||  $_POST['houseno'] == '' || $_POST['country'] == '-1' || $_POST['state'] == '-1' || $_POST['pincode'] == '' || $_POST['file'] == '-1' || $_POST['tc'] == ''){
        $ErrMsg="All * Fields Are Required";
    }else{
        $fname=$_POST['fname'];
        $lname=$_POST['lname'];
        $dob=$_POST['dob'];
        $d=implode("-", $dob);
        $d=trim($d,"-");
        $gender=$_POST['gender'];
        $hobbies=$_POST['hobbies'];
        $hobb=implode(",", $hobbies);
        $hobb=trim($hobb,",");
        $education=$_POST['education'];
        $edd=implode(",", $education);
        $edd=trim($edd,",");
        $email=$_POST['email'];
        $mobile=$_POST['mobile'];
        $landline=$_POST['landline'];
        $address=$_POST['address'];
        $houseno=$_POST['houseno'];
        $street=$_POST['street'];
        $location=$_POST['location'];
        $country=$_POST['country'];
        $state=$_POST['state'];
        $pincode=$_POST['pincode'];
        if (count($_FILES) > 0){

            $file=$_FILES['file']['name'];

            if ($_GET['edit']){
                if ($file==''){
                    $file=$_POST['hidden'];
                }
            }
            $upload="C:\Users\se56\Desktop\Images/".mktime();
            $uploadfile=$upload.basename($_FILES['file']['name']);
            if (move_uploaded_file($_FILES['file']['tmp_name'],$upload.$file)){
                //echo "File upload Sucess";
            }else {
                //echo "File uploading Fail";
            }
        }
        if (!preg_match("/^[a-zA-Z ]*$/", $fname) || !preg_match("/^[a-zA-Z ]*$/", $lname) || !preg_match("/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/", $email) || !preg_match("/^[0-9]{10}+$/", $mobile) || !preg_match("/^[0-9a-zA-Z]+$/", $address) || !preg_match("/^[0-9]+$/", $pincode)){
            $Err="Enter Details are Not Valid & Enter Valid Details";
        }else{
    $id=$_GET['edit'];
    $sql="select * from register where email=$email";
    $resqlt=mysqli_query($conn, $sql);
    if (mysqli_num_rows($result) > 0){
        echo "Already Exists";
    }else {
        if (!empty($id)){
            $sql="update register set fname='$fname',lname='$lname',dob='$d',gender='$gender',hobbies='$hobb',education='$edd',email='$email',mobile='$mobile',landline='$landline',address='$address',houseno='$houseno',street='$street',location='$location',country='$country',state='$state',pincode='$pincode',file='$file' where id=$id";
            header( "Location: registrationform.php" );
    }else{
            $sql="insert into register(fname,lname,dob,gender,hobbies,education,email,mobile,landline,address,houseno,street,location,country,state,pincode,file)values('$fname','$lname','$d','$gender','$hobb','$edd','$email','$mobile','$landline','$address','$houseno','$street','$location','$country','$state','$pincode','$file')";
            header( "Location: registrationform.php" );
    }
    if(mysqli_query($conn, $sql)){
        //echo "Insert Record Sucessfully"; 
    }else{
        echo "Could not insert record";
    }
        }
        }
    }
}
$count=array();
if ($_SERVER['REQUEST_METHOD']=='GET' && !empty($_GET['edit'])){
    $id=$_GET['edit'];
    $sql="select * from register where id=$id";
    $result=mysqli_query($conn, $sql);
    $row=mysqli_num_rows($result);
    if ($row > 0){
        while ($row=mysqli_fetch_assoc($result)){
            $count=$row;
        }
    }
    $edit_dob=array();
    $edit_dob=explode("-", $count['dob']);
    $edit_hobbies=array();
    $edit_hobbies = explode(",",$count['hobbies']);
    $edit_education=array();
    $edit_education=explode(",",$count['education']);
}
if ($_SERVER['REQUEST_METHOD']=='GET' && !empty($_GET['delete'])){
    $id=$_GET['delete'];
    $sql="delete from register where id=$id";
    $result=mysqli_query($conn, $sql);
    header( "Location: registrationform.php" );
}
$data=viewdata($conn);
showdata($data,$count,$edit_hobbies,$edit_education,$edit_dob,$ErrMsg,$Err);
function viewdata($con){
    $sql="SELECT register.id,register.fname,register.lname,register.dob,register.gender,register.hobbies,register.education,register.email,register.mobile,register.landline,register.address,register.houseno,register.street,register.location,country.country,register.state,register.pincode,register.file FROM register INNER JOIN country ON register.country=country.country_id";
    $result=mysqli_query($con, $sql);
    $row=mysqli_num_rows($result);
    if ($row > 0){
        while ($rows=mysqli_fetch_assoc($result)){
            $view[]=$rows;
        }
    }
    return $view;
}
?>
commented: VERY DANGEROUS CODE!! +0

@sriram_2, you revived a SIX YEAR OLD thread to post severely flawed and VERY DANGEROUS CODE?

I am not even going to get into everything wrong with what you posted. You need to do a lot more learning before you post a wall of code to "help".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.