Only logged in members can reply and interact with the post.
Join SimilarWorlds for FREE 禄

Which SW member do you wanna go on a date with?

This page is a permanent link to the reply below and its nested replies. See all post replies 禄
SW-User
Disturbed1226-30, M
@SW-User Mention someone!
MartinTheFirst26-30, M
@SW-User just say my name already!
SW-User
@MartinTheFirst 馃槕 馃ぃ
MartinTheFirst26-30, M
@SW-User i knew it!!
SW-User
@MartinTheFirst if going on a date only means having some fun, and maybe watching a movie, 馃 then.... Why not?
MartinTheFirst26-30, M
@SW-User and maybe a kiss on the cheek 馃槡?
SW-User
@MartinTheFirst Eww! No.
MartinTheFirst26-30, M
@SW-User 馃槶 *throws dress in garbage*
MartinTheFirst26-30, M
@SW-User Menas I solved it btw, it was super easy, I just had to change the hidden input into a textarea lulz
MartinTheFirst26-30, M
@SW-User however now I need to know how to give the textarea a max-length, a min-length, and no special characters
MartinTheFirst26-30, M
@SW-User nevermind menas, I solved it again...
MartinTheFirst26-30, M
@SW-User Menas how do you make it so that a person with a certain IP adress can't post more than one comment per day?
SW-User
@MartinTheFirst The textarea has the attributes rows, cols, and maxlength. You can use them to resize it.

There could be more than one person/device with the same IP address! :\
MartinTheFirst26-30, M
@SW-User yes but what are the chances that two people from the same ip-adress are gonna visit [i]my site and comment?[/i]

also I read that HTML rules for these things are unsafe, it's better to do it at the server-side.... idk im learning
SW-User
@MartinTheFirst Not unsafe. It's just not enough. You must do both, client side and server side validation. The client side input validation is it help the user enter the acceptable type of input, while the server validation is most important because the user can easily skip the client side but can't access the server side.
SW-User
@MartinTheFirst So, you wanna block the commenter's IP from commenting again, say for 24 hours? 馃
MartinTheFirst26-30, M
@SW-User okay but just server-side should suffice right? or should I do it on the html too incase... php fails or something?

people say that I should do this to grab IP-addresses, do you think it's reasonable?

[quote]public function getClientIP(){
if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)){
return $_SERVER["HTTP_X_FORWARDED_FOR"];
}else if (array_key_exists('REMOTE_ADDR', $_SERVER)) {
return $_SERVER["REMOTE_ADDR"];
}else if (array_key_exists('HTTP_CLIENT_IP', $_SERVER)) {
return $_SERVER["HTTP_CLIENT_IP"];
}

return '';
}

$IParray=array_values(array_filter(explode(',',$_SERVER['HTTP_X_FORWARDED_FOR'])));
return end($IParray);[/quote]
MartinTheFirst26-30, M
@SW-User yeah! i also want to save the IP adresses visiting my website so I can get some statistics
SW-User
@MartinTheFirst The server side validation is performed [i]after[/i] form submission. While the client side validation is good to tell the user about invalid data before they have to submit the page causing it to reload. Client side validation makes the form more user friendly, but yeah you can also make an "invalid input" message echos from php on form submission after reloading. But that wouldn't be very neat.

*Checking the code...*
MartinTheFirst26-30, M
@SW-User yeah I have the echo, it's not very neat as you say but It'll work for now
SW-User
@MartinTheFirst Most server save IP address of clients with their request details by default. You don't have to manage that.

The function getClientIp above is well defined to get the IP address of the client but the last part:
[quote]$IParray=array_values(array_filter(explode(',',$_SERVER['HTTP_X_FORWARDED_FOR'])));
return end($IParray);[/quote]
Makes absolutely no sense.
SW-User
@MartinTheFirst Getting the client's IP address is obviously not all you have to do.
SW-User
@MartinTheFirst You have to save a list of IP address that has commented, with the date and time each of which has commented. Such that each entry on the list has an expiration date, after which it's removed from the suspension list.
SW-User
@MartinTheFirst You can either save this list as a table in the SQL db or as a text file on the server
MartinTheFirst26-30, M
@SW-User 馃..馃く