Hi,I m working on a software product.Its working fine in localhost but not working on server.
Need help

Recommended Answers

All 6 Replies

Need more info... This is not very informative...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  
    <script type="text/javascript">
           //define the absolute path to your php script here
      var site_root='';
 
      //function to create ajax object
      function pullAjax(){
        var a;
        try{
          a=new XMLHttpRequest()
        }
        catch(b)
        {
          try
          {
            a=new ActiveXObject("Msxml2.XMLHTTP")
          }catch(b)
          {
            try
            {
              a=new ActiveXObject("Microsoft.XMLHTTP")
            }
            catch(b)
            {
              alert("Your browser broke!");return false
            }
          }
        }
        return a;
      }
      //this function does the ajax call, and appends cities into the second dropdown
      function populate_cities(x)
      {
        obj=pullAjax();
        var cities_list=document.getElementById('city');
        obj.onreadystatechange=function()
        {
          if(obj.readyState==4)
          {
            //returns comma separated list of cities after successful ajax request
            var tmp=obj.responseText;
            //split function returns array of city
            cities=tmp.split(',');
            //if second dropdown already has some data, CLEAR it
            if(cities_list.length>1)
              clean_cities(cities_list);
            //for loop to append the cities 
            var i=0;
            for(i=0;i<cities.length;i++)
              append_city(cities[i]);
          }
        };
        obj.open("GET",site_root+"cities_data.php?state="+x.value,true);
        obj.send(null);
      }
      //this gets call in the for loop and creates the options for the dropdown
      function append_city(city_value)
      {
        var cities_list=document.getElementById('city');
        cities_list.options[cities_list.options.length]=new Option(city_value,city_value,false,false);
      }
      //CLEARs the dropdown
      function clean_cities()
      {
        var cities_list=document.getElementById('city');
        cities_list.options.length=1;
      }
      //autoloads the city list, when the page first loads
      function autoload()
      {
        populate_cities(document.getElementById('state'));
      }
 

	function checkCheckBoxes() 
	{
		
		if(document.myform.chk1.checked)
	    {
	     document.myform.day.disabled=true;
	     document.myform.Month.disabled=true;
	    }
	    else
	    {
	       document.myform.day.disabled=false;
	       document.myform.Month.disabled=false;
	    }
	}

</script> 
<script type="text/javascript" src="select-nam.js"></script>
<script type="text/javascript" src="select-date.js"></script>

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<style type="text/css">
table, td, th
{
border:1px solid green;
font-family:Verdana;
font-size:small;
}
th
{
background-color:green;
color:white;
}
</style>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Members Details</title>
</head>

<body >
<form name="myform" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" enctype="multipart/form-data">
<table align="center" width="600px">
<tr>
<th colspan="2" height="2px">सदस्यों का विवरण</th>
</tr>
<tr>
<td align="right">नाम:&nbsp;&nbsp;
    <select style="float:right;" name="pre">
<option value="श्री" <?php if($_POST["pre"]=="श्री") echo "selected"; ?>>श्री</option>
<option value="Miss" <?php if($_POST["pre"]=="Miss") echo "selected"; ?>>Miss.</option>
   <option value="श्रीमती" <?php if($_POST["pre"]=="श्रीमती") echo "selected"; ?>>श्रीमती</option>
        <option value="डॉ"<?php if($_POST['pre']=="डॉ") echo "selected";?>>डॉ</option>
    </select>
</td>
<td>
<input type="text" name="name" value="<?php if(isset($_POST['name'])) echo $_POST['name']; ?>"/></td>
</tr>
<tr>
<td align="right"><select name="relation">&nbsp;&nbsp;
<option value="S/o श्री" <?php if($_POST["relation"]=="S/o श्री") echo "selected"; ?>>पिता का नाम</option>
<option value="W/o श्री" <?php if($_POST["relation"]=="W/o श्री") echo "selected"; ?>>पति का नाम</option>
<option value="S/o श्रीमती" <?php if($_POST["relation"]=="S/o श्रीमती") echo "selected"; ?>>माता का नाम</option>
</select></td>
<td><input type="text" name="father" value="<?php if(isset($_POST['father'])) echo $_POST['father']; ?>"></td>
</tr>
<tr>
<td align="right">राज्य:&nbsp;&nbsp;</td>
<td><select name="state" id="state" onchange="populate_cities(this);">
<option value="">Select State</option>
<option value="Delhi"<?php if($_POST["state"]=="Delhi") echo "selected"; ?>>Delhi</option>
<option value="Mumbai" <?php if($_POST['state']=="Mumbai") echo "selected"; ?>>Mumbai</option>

</select></td>
</tr>
<tr>
<td align="right">शहर:&nbsp;&nbsp;</td>
<td><select name="city" id="city">
<option>Choose city</option>
</select></td>
</tr>

<tr>
<td align="right">लिंग:&nbsp;&nbsp;</td>
<td><input type="radio" name="gender" value="male" <?php if($_REQUEST['gender'] == "male") echo "checked"; ?> style="height: 20px"/>Male
<input type="radio" name="gender" value="Female" <?php if($_REQUEST['gender'] == "Female") echo "checked"; ?>/>Female</td>
</tr>
<tr>
<td align="right">जन्म तिथि:&nbsp;&nbsp;</td>
<td>
<div style="float:left; width:auto;">
<select name="year" id="year">
    <?php
		for($y=1920; $y<=2012; $y++)
		{
	?>
		<option value="<?php echo $y; ?>" <?php if($y==$_POST["year"]) echo "selected"; ?> > <?php echo $y; ?> </option>
    <?php
		}
    ?>
    </select>

</div><?php
if(isset($_POST['submit']))
			$ccountry = $_POST['Month'];
			else
			$ccountry = '';
							
		 
		 $country_to_preselect = $ccountry;
		
						
			$options_month = array
			(
			''	 => '-- Select --', 
		    "1" => 'January',
			"2" => 'Feb',
			"3" => 'March',
			"4"=>'April',
		    "5"=>'May',
		    "6"=>'June',
		    "7"=>'july',
		    "8"=>'August',
		    "9"=>'September',
		    "10"=>'October',
		    "11"=>'November',
		    "12"=>'December'
						);
            	?>

<div style="float:left; width:auto; padding-left:10px;">
	<select name="Month" onchange="showdate(document.getElementById('year').value, this.value);">
	<?php
						foreach ($options_month as $index => $value)
						{
						    echo '    <option value="' . $index . '"';
						    if ($index == $country_to_preselect)
						    {
						        echo ' selected ';
						    }
						    echo '>' . $value . '</option>';
						}
					?>
	</select>
</div>
<div id="txtHint" style="width: 43px; float:left; padding-left:10px;">
 <select name="day" id="day">
    <?php
		for($d=1; $d<=31; $d++)
		{
	?>
		<option value="<?php echo $d; ?>" <?php if($d==$_POST["day"]) echo "selected"; ?> > <?php echo $d; ?> </option>
    <?php
		}
    ?>
    </select>
</div>
&nbsp;<input type="checkbox" name="chk1"  onclick='checkCheckBoxes()' value="1" <?php if ($_POST['chk1']=="1") echo 'checked="checked"'; ?>/>check for Birth year only</td>
</tr>

<tr>
<td align="right">नामदान तिथि:&nbsp;&nbsp;</td>
<td><div style="float:left; width:auto;">
<?php 
  $selectedYear = isset($_POST['year_nam']) ? $_POST['year_nam'] : $year; 
?>
<select name="year_nam" id="year_nam">
<?php
  for ($yr_nam = 1950; $yr_nam <= 2020; $yr_nam++) 
  {
   $selected = ($selectedYear == $yr_nam ) ? ' selected="selected"' : "";
       echo "<option value='$yr_nam' $selected>$yr_nam</option>";
  }
?>
</select></div>
<div style="float:left; width:auto; padding-left:10px;">
<?php
if(isset($_POST['submit']))
			$cmonth = $_POST['month_name'];
			else
			$cmonth = '';
							
		 
		 $country_to_preselect_month = $cmonth;
		
						
			$options_monthname = array
			(
			''	 => '-- Select --', 
		    "1" => 'January',
			"2" => 'Feb',
			"3" => 'March',
			"4"=>'April',
		    "5"=>'May',
		    "6"=>'June',
		    "7"=>'july',
		    "8"=>'August',
		    "9"=>'September',
		    "10"=>'October',
		    "11"=>'November',
		    "12"=>'December'
						);
            	?>

<select name="month_name"  onchange="shownaam(document.getElementById('year_nam').value, this.value);">
<?php
						foreach ($options_monthname as $index => $value)
						{
						    echo '    <option value="' . $index . '"';
						    if ($index == $country_to_preselect_month)
						    {
						        echo ' selected ';
						    }
						    echo '>' . $value . '</option>';
						}
					?>
	</select>


</div>
<div id="naamdaan" style="width: 43px; float:left; padding-left:10px;">
<select name="day_nam" id="day_nam">
    <?php
		for($dd=1; $dd<=31; $dd++)
		{
	?>
		<option value="<?php echo $dd; ?>" <?php if($dd==$_POST["day_nam"]) echo "selected"; ?> > <?php echo $dd; ?> </option>
    <?php
		}
    ?>
    </select>
	
</div>

&nbsp;</td>
</tr>
<tr>
<td align="right">फ़ोन नंबर:&nbsp;&nbsp;</td>
<td><input type="text" name="mobile" value="<?php if(isset($_POST['mobile'])) echo $_POST['mobile']; ?>" /></td>
</tr>
<tr>
<td align="right">फ़ोटो अपलोड करें:&nbsp;&nbsp;</td>
<td><input type="file" name="uploadedfile"/>(JPEG/PNG/GIF Format only)</td>
</tr>
<tr>
<td align="center"><a href="details.php">View Details</a></td>
<td align="center" style="padding-right:50px;"><input type="submit" name="submit" value="Submit" onclick="checkCheckBoxes()"/><input type="reset" name="reset" value="Reset"/></td>
</tr>
<script lang='javascript'>
checkCheckBoxes();
</script></table>
</form>
</body>

</html>
<?php
if(isset($_REQUEST['submit']))
 {
        $pre=$_POST['pre'];
        
	    if (isset($_POST['chk1']))
	    {
	      $dob=$_POST['year']."-"."00"."-"."00";
	    }
	    else
	    {
	      $dob=$_POST['year']."-".$_POST['Month']."-" .$_POST['day'] ; 
	    }
	    $namdan_date=$_POST['year_nam']."-".$_POST['month_name']."-" .$_POST['day_nam'] ;
	    $name=$_POST['name'];
	    $relation=$_POST['relation'];
	    $father=$_POST['father'];
	    $state=$_POST['state'];
	    $city=$_POST['city'];
	    $gender=$_POST['gender'];
	    $mobile=$_POST['mobile'];
	    $file = $_FILES['uploadedfile']['name'];
		$target_path="upload/";
		$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
		move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path);
		$fileatt = $target_path; // Path to the file
		$fileatt_type = "application/jpg"; // File Type
		$fileatt_name = substr($target_path,7); // Filename that will be used for the file as the attachment
		
		$name_of_uploaded_file =
		    basename($_FILES['uploadedfile']['name']);
		$size_of_uploaded_file =
		    $_FILES["uploadedfile"]["size"]/1024;
		
		$max_allowed_file_size = 1024; // size in KB
		
$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 "<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) {
$conn = mysql_connect('localhost','socadmin','admin@123#');
if(!$conn) die("Failed to connect to database!");
$status = mysql_select_db('soc');
if(!$status) die("Failed to select database!");
  mysql_query("SET NAMES utf8");
  //$result=mysql_query("Select * from tbl_hindi");
  mysql_query("INSERT INTO `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')");
                echo "<script type=\"text/javascript\">";
				echo "alert('Record has been added successfully !!');";
				echo "window.location='details.php'";
				echo "</script>";	
				echo "<script type=\"text/javascript\">";
  
  }
  }
?>

Where are you getting the error? what's not working. We can't hope to understand your entire code.

Give more information on the error etc. Thanks!

Javascript is not working on the failure of validation.

Why then do you post this in PHP?
Also you need to be more precise. What does not work, why do you think that is, and what is the code we should be looking at? Also, do some debugging. Log or alert some variables, check that they're correct, et cetera.

Post this to the Javascript forum, your javascript functions which does not work.

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.