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:
Is the code for checking the values of a column somethings like the following ?
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
..
}
?>
Hi,
enabled the server side validation and try this :
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!!!!";
}
?>
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 =& ?
😀
Max, I would like to know a bit more about the syntax: $database =& JFactory::getDBO();
What is the difference between = and =& ?
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
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
This topic is locked and no more replies can be posted.