ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

Ip address check

gg4j 22 Nov, 2008
Hi everybody, first thanks for assistance because I got finally the point and I am almost there.
I chop the problem in simple things to sort out what I need 😀

So I want to avoid the user to sumbit data two times from the same cpmputer.
To do this, I have to confront his IP with the ones already stored in the column "ipaddress" of a "cf_table".

How to do that? I am looking at some doumentation of mysql, please some light.lightbulb
I guess should be a cyle.


The current IP address is given by:

 JRequest::setVar( "ipaddress", JRequest::getVar( "ipaddress", $_SERVER["REMOTE_ADDR"], "post", "string", "" ));


Is the code for checking the values of a column somethings like the following ?

<?php
$sql = "SELECT Ipaddress from cf_table";
$result = mysql_query($sql);

while ($_SERVER["REMOTE_ADDR"] = mysql_fetch_field($result))
  {
..
DO the autogenerated code
for allowing the user subit the data to cf_table
.. 
  }

?>
Max_admin 22 Nov, 2008
Hi,

enabled the server side validation and try this :

<?php
global $mainframe;
$database =& JFactory::getDBO();
$sql = "SELECT * FROM cf_table WHERE ipaddress='".$_SERVER["REMOTE_ADDR"]."'";
$database->setQuery( $sql );
$result = $database->loadObject();
if($result){
return "No man, you can't post again!!!!";
}
?>


Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
gg4j 23 Nov, 2008
Thank you so much, it works great.
😀
Max, I would like to know a bit more about the syntax: $database =& JFactory::getDBO();
What is the difference between = and =& ?
GreyHead 23 Nov, 2008
Hi gg4j,

It a bit technical but = creates a new copy of the the Database object in the server memory and =& just create a pointer to the original copy. As the database object only provides functions to access the database and doesn't have any variables that might conflict you should always use the =& method to point to it.

Bob
gg4j 27 Nov, 2008
Hi Greyhead...
thanks for the starter: I can now look for more details by myself, thanks a lot!
😀
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com