Hi,I am working on this code.the problem is its not going to 2nd elseif(upload).
need suggestion.

if(empty($mobile))
		 {
		      echo '<script language="javascript">alert("Enter Phone Number")</script>;';
		 }     
		  
		elseif(!(empty($mobile)))
		    {
		       if((is_numeric($mobile)))
		           { 
					      if((strlen($mobile)!=10))
						      echo '<script language="javascript">alert("phone number should be of 10 digit")</script>;';
				   }
		   	   else
			   	    {
			        echo '<script language="javascript">alert("Please Enter valid phone number")</script>;';
					}
	        }
	        
	       elseif(!($_FILES["uploadedfile"]["type"]=="image/pjpeg" ||  $_FILES["uploadedfile"]["type"]=="image/jpeg" ||  $_FILES["uploadedfile"]["type"]=="image/jpg" ||  $_FILES["uploadedfile"]["type"]=="image/png"))
	       
		    { 
		    
                echo "i am in upload";		    
    			echo "<script language=\"javascript\">alert(\"Your uploaded file must be of JPG or GIF. Other file types are not allowed!!\")</script>;";  
		        echo "<script type='text/javascript'>";
		        echo "</script>";
		    }
       
   		else
		{
		mysql_connect('localhost','root','');
		mysql_select_db('project');
		mysql_query("SET NAMES utf8");
		//$result=mysql_query("Select * from tbl_hindi");
        echo("INSERT INTO `project`.`tbl_hindi` (`pre`, `name`, `father`, `state`, `city`, `gender`, `mobile`, `dob`, `namdan_date`, `file` ,`relation`)VALUES ('$pre','$name','$father','$state','$city','$gender','$mobile','$dob','$namdan_date','$file','$relation')");		
		}

It's easier to troubleshoot if you arrange your code neatly, like this:

<?php
if (empty($mobile)) {
  echo '<script language="javascript">alert("Enter Phone Number")</script>;';
  }
elseif (!(empty($mobile))) {
  if ((is_numeric($mobile))) {
    if ((strlen($mobile)!=10))
      echo '<script language="javascript">alert("phone number should be of 10 digit")</script>;';
    }
  else {
    echo '<script language="javascript">alert("Please Enter valid phone number")</script>;';
    }
  }
elseif (!($_FILES["uploadedfile"]["type"]=="image/pjpeg" ||  $_FILES["uploadedfile"]["type"]=="image/jpeg" ||  $_FILES["uploadedfile"]["type"]=="image/jpg" ||  $_FILES["uploadedfile"]["type"]=="image/png")) { 
  echo "i am in upload";		    
  echo "<script language=\"javascript\">alert(\"Your uploaded file must be of JPG or GIF. Other file types are not allowed!!\")</script>;";  
  echo "<script type='text/javascript'>";
  echo "</script>";
  }
else {
  mysql_connect('localhost','root','');
  mysql_select_db('project');
  mysql_query("SET NAMES utf8");
  //$result=mysql_query("Select * from tbl_hindi");
  echo("INSERT INTO `project`.`tbl_hindi` (`pre`, `name`, `father`, `state`, `city`, `gender`, `mobile`, `dob`, `namdan_date`, `file` ,`relation`)VALUES ('$pre','$name','$father','$state','$city','$gender','$mobile','$dob','$namdan_date','$file','$relation')");
  }
?>

That makes it easier to work out what is going wrong. If you examine your logic closely you'll see that it will never get to the Upload section (or the mysql section). Why? Because you code is effectively saying (in pseudo-code):

if (is empty) {
  // do stuff
  }
elseif (is not empty) {
  // do other stuff
  }
elseif (some other condition) {
  // do upload stuff
  }
else {
  // do mysql stuff
  }

The variable is either empty or not empty, so that's why it never gets to upload stuff. It's like saying "If it's raining then put on your raincoat, if it's not raining then put your raincoat away, otherwise go shopping". You never get to go shopping because you only end up follow the first two branches because it's eitehr raining or it isn't! There's no third option on the boolean.

Here's the logic I think you want:

<?php
$fail = false;
if (empty($mobile)) {
  echo '<script language="javascript">alert("Enter Phone Number")</script>;';
  $fail = true;
  }
else {
  if ((is_numeric($mobile))) {
    if ((strlen($mobile)!=10)) {
      echo '<script language="javascript">alert("phone number should be of 10 digit")</script>;';
      $fail = true;
      }
    }
  else {
    echo '<script language="javascript">alert("Please Enter valid phone number")</script>;';
    $fail = true;
    }
  }
if (!($_FILES["uploadedfile"]["type"]=="image/pjpeg" ||  $_FILES["uploadedfile"]["type"]=="image/jpeg" ||  $_FILES["uploadedfile"]["type"]=="image/jpg" ||  $_FILES["uploadedfile"]["type"]=="image/png")) { 
  echo "i am in upload";		    
  echo "<script language=\"javascript\">alert(\"Your uploaded file must be of JPG or GIF. Other file types are not allowed!!\")</script>;";  
  echo "<script type='text/javascript'>";
  echo "</script>";
  $fail = true;
  }
if (!$fail) {
  mysql_connect('localhost','root','');
  mysql_select_db('project');
  mysql_query("SET NAMES utf8");
  //$result=mysql_query("Select * from tbl_hindi");
  echo("INSERT INTO `project`.`tbl_hindi` (`pre`, `name`, `father`, `state`, `city`, `gender`, `mobile`, `dob`, `namdan_date`, `file` ,`relation`)VALUES ('$pre','$name','$father','$state','$city','$gender','$mobile','$dob','$namdan_date','$file','$relation')");
  }
?>
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.