king king - 6 months ago 19
PHP Question

recover from that IP sends an email

Is it possible to add a code to retrieve IP of the sender
a customer review?

I feel that something is missing in this variable because I am not able to retrieve the IP with my PHP scripts. For the moment I have:

PHP code:

$print("Votre adresse IP est : $_SERVER['REMOTE_ADDR']");


And:

// Code for sending mail when a new testimonial has been Added
if ( $rset && mysqli_affected_rows($link)>0 ) {
$to = $useremail;
$subject = 'Nouveau Témoignage Ajouté';
$message = "Témoignage Détails". "\r\n" ;
$message .='Nom du client :'.stripslashes( $client_id ). "\r\n" ;
$message .='Témoignage :' .stripslashes( $feedback ). "\r\n" ;
$headers = 'De:' .$to . "\r\n" ;
@mail( $to, $subject, $message, $headers );
$successmsg = "Témoignage a été ajouté avec succès.";
}else if ( mysqli_errno($link)) {
$errmsg = mysqli_errno($link);
}else {
$errmsg = "Ajout Témoignage échoué.";
}
}else{

if( $validate != 'true' ) {
$errmsg = $validate;
}
}
}
?>


issue here
add the function id #checkbox

<script type="text/javascript">
function validatefrm()
{
var frm = document.addform;
var x = document.forms["addform"]["emailid"].value;
var atpos = x.indexOf("@");
var dotpos = x.lastIndexOf(".");

var ratingtype = jQuery('.ratingtype').val();
if (ratingtype == 'custom' ) {
var rating = jQuery('.customratings');
} else if (ratingtype == 'ratings' ) {
var rating = jQuery('.rating');
}
if ( frm.client_id.value === "" ) {
alert("Entrez le nom du client pour le Commentaires.");
frm.client_id.focus();
return false;
}

else if( frm.emailid.value === "" ) {
alert("Entrez l'adresse e-mail");
frm.emailid.focus();
return false;
}
else if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) {
alert("Not a valid e-mail address");
frm.emailid.focus();
return false;
}
else if ( frm.day.value === "" ) {
alert("Sélectionnez jour");
frm.day.focus();
return false;
}
else if ( frm.month.value === "" ) {
alert("Sélectionnez un mois");
frm.month.focus();
return false;
}
else if ( frm.year.value === "" ) {
alert("Sélectionnez Année");
frm.year.focus();
return false;
}

else if ( frm.proj_desc.value === "" ) {
alert("Entrez le titre pour le projet ");
frm.proj_desc.focus();
return false;
}
else if( frm.companyname.value === "" ) {
alert("Entrez le nom ou site web entreprise ");
frm.companyname.focus();
return false;
}
else if( frm.feedback.value === "" ) {
alert("Entrez Témoignage");
frm.feedback.focus();
return false;
}
else if( frm.captcha.value === "" ) {
alert("Enter captcha");
frm.captcha.focus();
return false;
}
else if (jQuery("#checkbox").prop("checked")==false) {
alert("Cochez cette case si vous acceptez les termes et conditions.");
frm.checkbox.focus();
return false;
}

return true;
}

jQuery(document).ready(function($) {
jQuery('.select_wrapper').each(function () {
jQuery(this).prepend('<span>' + jQuery(this).find('.select option:selected').text() + '</span>');
});
jQuery('.select').on('change', function () {
jQuery(this).prev('span').replaceWith('<span>' + jQuery(this).find('option:selected').text() + '</span>');
});
});




add “name” checkbox and “id” checkbox
code is correct

<div class="item">
<div class="checkbox">
<label>
<input type="checkbox" name="checkbox" id="checkbox" > En continuant, vous acceptez les <a href="cgu.php"><span class="skin-color">Conditions générales</span></a>.
</label>
</div>
</div>


Thank you

Answer

use this function for get client IP

<?PHP 

function GetIP()
    {
        if ( getenv("HTTP_CLIENT_IP") ) {
            $ip = getenv("HTTP_CLIENT_IP");
        }
        elseif ( getenv("HTTP_X_FORWARDED_FOR") ) {
            $ip = getenv("HTTP_X_FORWARDED_FOR");
            if ( strstr($ip, ',') ) {
                $tmp = explode(',', $ip);
                $ip  = trim($tmp[0]);
            }
        }
        else {
            $ip = getenv("REMOTE_ADDR");
        }

        return $ip;
    }


        // Code for sending mail when a new testimonial has been Added
    if ( $rset && mysqli_affected_rows($link)>0 ) {
        $to         = $useremail;                    
        $subject    = 'Nouveau Témoignage Ajouté';
        $message    = "Témoignage Détails". "\r\n" ;
        $message    .='Nom du client :'.stripslashes( $client_id ). "\r\n" ;
        $message    .='Témoignage :' .stripslashes( $feedback ). "\r\n" ;
        $message    .='Votre adresse IP est :' .GetIP(). "\r\n" ;
        $headers    = 'De:' .$to . "\r\n" ;
        @mail( $to, $subject, $message, $headers );
        $successmsg  =  "Témoignage a été ajouté avec succès.";
    }else if ( mysqli_errno($link)) {
        $errmsg =  mysqli_errno($link);
    }else {
        $errmsg = "Ajout Témoignage échoué.";
    }   
}else{

    if(  $validate != 'true' ) {
        $errmsg = $validate;
    }
}
}
?>