Error Code!

Dears, i have the following code for my landing pages that will push the information to SugarCRM, for some reason and i dont know why, when a client register it sometimes the client information appears empty in my sugarcrm, can you please help to identify the issue.
the code is:

<form onsubmit="return validateForm()" action="http://---------.net/crm/index.php?entryPoint=WebToLeadCapture" name="WebToLeadForm" method="POST" id="contact_form" name="myForm">
     <div id="result"></div>
	<input type="text" name="last_name" id="last_name" placeholder="اسمك هنا" class="pix_text" required>
	     <div dir="rtl" style="display:none; color: whitesmoke; !important;" id="name-valid1" class="alert alert-danger">الرجاء ادخال الاسم بشكل صحيح</div>
	     <input type="email" name="email1" id="email1" placeholder="بريدك الالكتروني هنا" class="pix_text" required>
	     <div dir="rtl" style="display:none; color: whitesmoke; !important;"id="email-valid1"  class="alert alert-danger">الرجاء ادخال البريد الالكتروني بشكل صحيح</div>
	     <input type="text" name="phone_mobile" id="phone_mobile" placeholder="رقم هاتفك هنا" class="pix_text" pattern="[0-9]{10}" required>
	     <button class="subscribe_btn pix_text" onclick="submit_form()" id="submitform">
	          <span class="editContent">أرسل بياناتك الآن</span>
             </button>							
             <div dir="rtl" style="display:none; color: whitesmoke; !important;"id="phone-valid1"  class="alert alert-danger">الرجاء ادخال رقم الهاتف بشكل صحيح</div>
             <input type="hidden" id="lead_source" name="lead_source" value="sitedisplay">
             <input type="hidden" id="campaign_id" name="campaign_id" value="9189b8f0-2729-ba7c-d17c-55b34c5fc40b" />
             <input id="assigned_user_id" type="hidden" name="assigned_user_id" value="1" />

             <input type="hidden" id="redirect_url" name="redirect_url" value="http://--------.com/thankYouPage">
	     <?php
		  $client  = @$_SERVER['HTTP_CLIENT_IP'];
		  $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
		  $remote  = @$_SERVER['REMOTE_ADDR'];
		  $result  = array('country'=>'', 'city'=>'');
		  if(filter_var($client, FILTER_VALIDATE_IP)){
			$ip = $client;
		  }elseif(filter_var($forward, FILTER_VALIDATE_IP)){
			$ip = $forward;
		  }else{
			$ip = $remote;
		  }
		  $ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));    
		  if($ip_data && $ip_data->geoplugin_countryName != null){
		       $result['country'] = $ip_data->geoplugin_countryCode;
		       $result['city'] = $ip_data->geoplugin_city;
		  }
								
            ?>
     <br>
     <input type="hidden" name="primary_address_country" id="primary_address_country" value="<?php echo $result['country'].",".$result['city']; ?>">
</form>
<script>
function validateForm1() {
	var x = $("#last_name1").val();
	var y = $("#phone_mobile1").val();
	var z = $("#email11").val();
	var x1 = 0; x2 = 0; x3 = 0;
    if (x == null || x == "" || y == null || y == "" || z == null || z == "" ) {
        $("#name-valid1").show(300).delay(3000).hide(300);
        $("#email-valid1").show(300).delay(3000).hide(300);
        $("#phone-valid1").show(300).delay(3000).hide(300);
	
        return false;
    } else {
		x1 = 1;
	}
	if(!y.match(/\d{10}/g)) {
        $("#phone-valid1").show(300).delay(3000).hide(300);
	
        return false;
	} else {
		x2 = 1;
	}
	if(!z.match(/\S+@\S+\.\S+/i)) {	
        $("#email-valid1").show(300).delay(3000).slideUp(300);
		
        return false;
	} else {
		x3 = 1;
	}
	if(x1 == 1 && x2 == 1 && x3 == 1){
		$("#submitb").attr('disabled','disabled');
    
		return true;
	}
}
</script>

Which data ‘appears empty’?

Also an aside, you dont need the x1,x2,x3 or any of the 'else’s in your code at the bottom there - if you encounter a fail state, you return from the function before you even get to the if.

the name, email and the phone number

That would make sense. The function is using id selectors that don’t exist in the form.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.