-3

I need to capture the IP Address of visitors who opt to fill up the WebToLead Form created in SuiteCRM. I am able to capture the data of visitor in fields such as First Name, Last Name, Email ID, but not IP address of the visitor.

Here is the complete code of this webtoLead form: which I have created:

<html lang='en_us'><head><base target=”_parent” /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body><style type="text/css"><!--
form#WebToLeadForm, form#WebToLeadForm * {margin: 0; padding: 0; border: none; color: #333; font-size: 12px; line-height: 1.6em; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;}
form#WebToLeadForm {float: left; border: 1px solid #ccc; margin: 10px;}
form#WebToLeadForm h1 {font-size: 32px; font-weight: bold; background-color: rgb(60, 141, 188); color: rgb(247, 247, 247); padding: 10px 20px;}
form#WebToLeadForm h2 {font-size: 24px; font-weight: bold; background-color: rgb(60, 141, 188); color: rgb(247, 247, 247); padding: 10px 20px;}
form#WebToLeadForm h3 {font-size: 12px; font-weight: bold; padding: 10px 20px;}
form#WebToLeadForm h4 {font-size: 10px; font-weight: bold; padding: 10px 20px;}
form#WebToLeadForm h5 {font-size: 8px; font-weight: bold; padding: 10px 20px;}
form#WebToLeadForm h6 {font-size: 6px; font-weight: bold; padding: 10px 20px;}
form#WebToLeadForm p {padding: 10px 20px;}
form#WebToLeadForm input,
form#WebToLeadForm select,
form#WebToLeadForm textarea {border: 1px solid #ccc; display: block; float: left; min-width: 170px; padding: 5px;}
form#WebToLeadForm select {background-color: white;}
form#WebToLeadForm input[type="button"],
form#WebToLeadForm input[type="submit"] {display: inline; float: none; padding: 5px 10px; width: auto; min-width: auto;}
form#WebToLeadForm input[type="checkbox"],
form#WebToLeadForm input[type="radio"] {width: 18px; min-width: auto;}
form#WebToLeadForm div.col {display: block; float: left; width: 330px; padding: 10px 20px;}
form#WebToLeadForm div.clear {display: block; float: none; clear: both; height: 0px; overflow: hidden;}
form#WebToLeadForm div.center {text-align: center;}
form#WebToLeadForm div.buttons {padding: 10px 0; border-top: 1px solid #ccc; background-color: #f7f7f7}
form#WebToLeadForm label {display: block; float: left; width: 160px; font-weight: bold;}
form#WebToLeadForm span.required {color: #FF0000;}
--></style>
<!-- TODO ??? 
<script type="text/javascript" src='http://localhost/suitecrm/cache/include/javascript/sugar_grp1.js?v=WCpISilUvngJZgJBZ4o1BA'></script> 
--><form id="WebToLeadForm" action="http://localhost/suitecrm/index.php?entryPoint=WebToPersonCapture" method="POST" name="WebToLeadForm">
<h2>FREE Blog Subscription - IT & Networking Blog</h2>
<p style="text-align: center;">Submitting this form will add you to subscription list of IT & Networking Blog. You will receive email about each new post as soon as published.</p>
<p><img src="http://localhost/images/banners/LeadManagement/Blog-Subscription-image.png" alt="" /></p>
<div class="row">
<div class="col"><label>First Name: <span class="required">*</span></label><input name="first_name" id="first_name" type="text" required="" /></div>
<div class="col"> </div>
<div class="clear"> </div>
</div>
<div class="row">
<div class="col"><label>Last Name: <span class="required">*</span></label><input name="last_name" id="last_name" type="text" required="" /></div>
<div class="col"> </div>
<div class="clear"> </div>
</div>
<div class="row">
<div class="col"><label>Email Address: <span class="required">*</span></label><input name="email1" id="email1" type="email" required="" /></div>
<div class="col"> </div>
<div class="clear"> </div>
</div>

<p style="text-align: center;">Select the target lists, you want to join:</p>


<input type="checkbox" id="IT" value="IT">IT<br>
<input type="checkbox" id="Process" value="Process">Process<br>
<input type="checkbox" id="Management" value="Management">Management<br>
<input type="checkbox" id="Education" value="Education">Education<br>


<p style="text-align: center;">100% Privacy! We will never spam you.</p>

<div class="row center buttons" style="text-align: center;"><input class="button" name="Submit" type="submit" value="Subscribe" onclick="submit_form();" />
<div class="clear"> </div>
</div>
<input name="campaign_id" id="campaign_id" type="hidden" value="13f62ae3-f38d-fe80-a93a-57d87643f4b7d" /> <input name="assigned_user_id" id="assigned_user_id" type="hidden" value="1" /> <input name="moduleDir" id="moduleDir" type="hidden" value="Prospects" /><input name="prospect_list_id" id="prospect_list_id" type="hidden" value="ac6ce628-de45-4813-d1a0-57e2rd432146" />

<!--my code starts here -->
<input name="list_name_c" id="list_name_c" type="hidden" value="poello" /></div>


</form>


<p>
<script type="text/javascript">// <![CDATA[
function submit_form()
{

if (typeof(validateCaptchaAndSubmit) != 'undefined')
{
validateCaptchaAndSubmit();
}
else
{
check_webtolead_fields();
//document.WebToLeadForm.submit();
check();

}


}


function check_webtolead_fields()
{
if (document.getElementById('bool_id') != null)
{
var reqs = document.getElementById('bool_id').value;
bools = reqs.substring(0, reqs.lastIndexOf(';'));
var bool_fields = new Array();
var bool_fields = bools.split(';');
nbr_fields = bool_fields.length;
for (var i = 0; i < nbr_fields; i++)

{
if (document.getElementById(bool_fields[i]).value == 'on')
{
document.getElementById(bool_fields[i]).value = 1;
}
else
{
document.getElementById(bool_fields[i]).value = 0;
}
}
}

}


function check()
{

var list_name = "";
var test = document.forms[0];
var txt = "";
var i;

for (i = 0; i < test.length; i++)
{
if (test[i].checked)
{
txt = txt + test[i].value + " ";
}
}
list_name = txt;
alert(list_name);

document.getElementById('list_name_c').value = list_name;

}



// ]]></script>
</p></body></html>

I have scanned through 100s of webpages w.r.t., IP Address Capturing, but no page provided sufficient information about how to do it in SuiteCRM or SugarCRM.

No forum member of SuiteCRM or SugarCRM also could provide 'precise' and 'correct' instruction.

Kindly help w.r.t.
I need to capture the IP address of user who fills up the WebToPerson form and to pass this value to a custom field 'created_ip_address_c' which I have created in table 'prospects'.

You help is solicited.

With thanks,

RK

Environment is: PHP 5.4.3 MySQL Apache

Rajneesh
  • 15
  • 5

1 Answers1

0
  • Within SugarCRM, Add a field to hold the IP Address to your Leads module
  • Add this field to your Web to Lead form, but alter the HTML so that it is a hidden input
  • Within the site that holds your webform, capture the user's IP address and add it to then hidden input
  • Post form data to Sugar as normal
MartinTawse
  • 321
  • 2
  • 10
  • Dear Martin, I understood all of your points, except 3rd one. I have already added a field 'created_ip_address_c' in prospects table using Studio. I intend to use the code given at URL: http://blackbe.lt/advanced-method-to-obtain-the-client-ip-in-php/ ...as I understand that I would be able to capture the Ip address in PHP, but how to pass this value to form field (hidden, as suggested by you). I don't know how to achieve all this. Please lend me your helping hand! Thanks. – Rajneesh Oct 17 '16 at 18:18
  • http://stackoverflow.com/questions/29829860/hide-input-type-hidden-name-userip-value-php-echo-serverremote-addr – MartinTawse Oct 18 '16 at 08:07
  • Can you tell me in the language of -- – Rajneesh Oct 18 '16 at 14:01
  • "What code to insert and Where?" in terms of above form code. I don't have sufficient knowledge to decipher the post you have shared. – Rajneesh Oct 18 '16 at 14:02
  • The link I posted demonstrates how to place the users IP address into a hidden input in a web form written in PHP. Just give this input the same name as your Sugar field. Which bit do you not understand? What have you tried so far? – MartinTawse Oct 18 '16 at 14:15
  • should I place the following code just above the syntex : – Rajneesh Oct 18 '16 at 15:05
  • Yes, just make sure it's within the form tags and it will be posted with the rest of the form data, – MartinTawse Oct 18 '16 at 15:21
  • It is not working as expected, it passed the following snippet to database table: More guidance is solicited. Thanks! – Rajneesh Oct 18 '16 at 19:19
  • I am able to capture the IP Address in a php variable $ipaddress, but How can I pass the value of this variable to MySQL table field of 'created_ip_address_c' – Rajneesh Oct 18 '16 at 21:00
  • In fact, the original question is still valid, as to getting this php variable value in to Java Script of form itself. Question is How? – Rajneesh Oct 18 '16 at 22:00
  • The problem is with your webform, not SugarCRM. It seems that PHP is not being parsed, but there is no information about your webserver, I don't even know if it is PHP based. I suggest you start a new topic concentrating on the actual issue listing all the information you have about the webserver hosting the webform. – MartinTawse Oct 19 '16 at 10:11
  • There was no problem with Form or Webserver which was running with Linux, Apache, MySQL and PHP environment. – Rajneesh Oct 19 '16 at 20:11
  • Is your web form running as a PHP script? If you're executing PHP code inside it it will need the .php extension rather than .html. – MartinTawse Oct 20 '16 at 09:44
  • I was pasting the form code in the 'Custom' HTML module within Joomla. However the solution have been found. – Rajneesh Oct 20 '16 at 10:17
  • I have found the solution and want to share it here. But when I attempt to post answer, it is showing a warning as given here: We are no longer accepting answers from this account. See the Help Center to learn more. – Rajneesh Oct 20 '16 at 10:30