php - How to retrieve the comment IP -


i need code displays ip of person/guest commented on website. here's index page;

<?php include "core/init.php";  ?>   <!doctype html>    <link rel="stylesheet" type="text/css" href="http://hjalplista.comxa.com/daniel_emelie/style.css">  <meta http-equiv="content-type" content="text/html;charset=utf-8"> <title>välkommen till hjälplistan!</title>    <body> <div id="header"> <div align="right"><a href="http://www.helsingborg.se/wieselgrensskolan" target="_blank"><img src="http://i.imgur.com/y0ainit.jpg"></a></div> </div>  <div id="inside">  <center>  <div id="location"><a href='index.php'>hem</a> - <a href='administrative/adminonlyaccess.php'><i>admin</i></a><br><br> </div> <hr/>   <br>   <div id="text"> <br>  <table border="1" cellpadding="1" cellspacing="1" style="width: 100%;">     <tbody>         <tr>             <td><span style="color:slategray;"><strong><center>nr</center></strong></span></td>             <td><span style="color:slategray;"><strong><s><center>fått hjälp</center></s></strong></span></td>             <td><span style="color:slategray;"><strong><center>namn</center></strong></span></td>             <td><span style="color:slategray;"><strong><center>uppgift</center></strong></span></td>             <td><span style="color:slategray;"><strong><center>ip-adress</center></strong></span></td>         </tr>  <?php include "core/inc/conn.php";  mysql_select_db("comments");  $getquery = mysql_query("select * comments order id desc"); while($rows = mysql_fetch_assoc($getquery)) {        $id = $rows['id'];      $comment_name = $rows['name'];      $comment = $rows['comment'];         echo"<tr><th><font color='lightgray'>$id</font></th>";      echo"<th><font color='red'>fungerar ej!</font></th>";      echo "<th><u><font color='black'>$comment_name</font></u></th>";      echo"<th><font face='black'>$comment</font></th>";      echo"<th></th></tr>";         }      if(isset($_get['error'])) {     echo "<p>15 bokstäver max!";  }   ?>  </table>  <br><br> </body> <head> <center>   </div>  <br><br>   <form action="post_comment.php" method="post">  <label> namn: <input type="text" name="name"></label><br><br> <label> uppgift: <input type="text" name="comment"></label><br><br> <input type="submit" name="post" value="skicka">  </form>    <br><br>   <br><br>  <?php echo "<br><br><br>"; echo "<hr/>"; echo "<p> &copy; wieselgrenskolan. rights reserved. </p>";  ?>  </head> </html>  <html>  <div align="right">  <!-- start of hit counter code --> <br><script language="javascript" src="http://www.counter160.com/js.js?img=11"></script><br><a href="http://www.000webhost.com"><img src="http://www.counter160.com/images/11/left.png" alt="free web hosting" border="0" align="textright"></a><a href="http://www.hosting24.com"><img alt="web hosting" src="http://www.counter160.com/images/11/right.png" border="0" align="texttop"></a> <!-- end of hit counter code -->  </div> </html> 

and it's supposed in echo "<th></th></tr>";. need mysql table that?

i've created index in mysql called ''commentip'' don't know how fix missing parts.

you can ip in php in cases using $_server['remote_addr'] if using proxy or using reverse proxy cloudflare or incapsula can use $_server['http_x_forwarded_for'].


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -