Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
Hello, I'm wondering if it's possible to get the senders ip address through the contact form. Is there an undocumented couch tag or some handy php stuff to achieve that? In some cases I want to know the senders country of origin to avoid phishing/spam.

I found a php snippet to show the Ip address but got no idea how to implement that into the contact form.

Code: Select all
<?php
    $ip = $_SERVER["REMOTE_ADDR"]; 
    $host = gethostbyaddr($ip);

    echo "IP Adresse: $ip<br>"; 
    echo "Hostname: $host"; 
?>


Thanks for any idea or help
best Christoph
Hi Christoph,

Using PHP from within Couch is simple. You can easily use the code snippet you posted with minimal changes (use <cms:php>..</cms:php> instead of <?php .. ?>)
Code: Select all
<cms:php>
    $ip = $_SERVER["REMOTE_ADDR"];
    $host = gethostbyaddr($ip);

    echo "IP Adresse: $ip<br>";
    echo "Hostname: $host";
</cms:php>

Place the above snippet within the cms:send_mail block of the contact form and you should receive its output in the mail.

Hope this helps.
Thank you very much!
3 posts Page 1 of 1
cron