Re: [PHP] $_POST['name'] [HELP]
That means only the given IP address can post...? (if the username is not 'Superfun') I thought everyone should be able to post...?
I think instead of || it should be &&, so nobody can post with the name Superfun only Superfun himself (because of the IP address)
Re: [PHP] $_POST['name'] [HELP]
&& allows from everbody, i tested
EDIT: || works, thanks
Re: [PHP] $_POST['name'] [HELP]
&& must work, you sure you implemented it right?
PS: if ($var == 0) equals if (!$var), but you can also use if/else structure, that way you dont need $var. (ie: if (blah) {[error]} elseif (blah) {[error]} else {[if no error was found]}). Except if you want to display all error at once.
PPS: I like the idea of a sig chat :)
Re: [PHP] $_POST['name'] [HELP]
Quote:
Originally Posted by
Superfun
I have an sigchat, but what i get, ppl will post under my name,
What can i do sow they get an another page when they post under the name Superfun
What i tried(and not worked):
PHP Code:
<?php
if (($_POST['naam'])==superfun);
echo "test";
exit()
?>
What if your IP is dynamic? Why not just do:
PHP Code:
<?php
$name = $_POST['naam']; // name data
$check = strtolower($name); // converts the username to lower case
$done = ucfirst($check); // capitalizes first letter
$ip = $_SERVER['REMOTE_ADDR']; // gets ip address
if($check == Superfun AND $ip = yourip){ // remember case sensitive
die "test";
}
?>
Whatever they type, it will always convert to lower case, then capitalize the first letter.
For instance; if a user enters SUPERFUN, $check will convert it to superfun and then $done will convert it to Superfun, thus checking the user's IP address.
Re: [PHP] $_POST['name'] [HELP]
Shouldn't the text be between quotes?: if ($check=="superfun")
You can also use eregi("superfun", $_POST['name']);, this checks (case unsensitive) if the name containes the combination of characters "superfun". So "DaSuperfunman" will give error and "IHAVESUPERFUN" too and "superfunxx0r" too etc etc.
Re: [PHP] $_POST['name'] [HELP]
Daevius, I'm not quite sure which version this was introduced, but you don't need to use quotes for short text anymore [I may be wrong there but it works for me].
Re: [PHP] $_POST['name'] [HELP]
String comparisons should always use quotes. PHP will interpret text as strings if it can't find a valid type, but this causes an E_NOTICE class error, is slower and in general ugly.
Re: [PHP] $_POST['name'] [HELP]
Quote:
Originally Posted by
FragFrog
String comparisons should always use quotes. PHP will interpret text as strings if it can't find a valid type, but this causes an E_NOTICE class error, is slower and in general ugly.
The more important matter is; it works. I don't care if it looks ugly. Some coding (like OOP) looks like ugly coding, but it still works. Also, I fail to see how it can cause an E_NOTICE class error when it definitely works without writing to the error log. Also, it's not slower. If anything, it's quicker as there is less coding.
PHP Code:
<?php
$name = $_POST['naam']; // name data
$check = strtolower($name); // converts the username to lower case
$done = ucfirst($check); // capitalizes first letter
$ip = $_SERVER['REMOTE_ADDR']; // gets ip address
if($check == Superfun AND $ip == yourip){ // remember case sensitive
die("test");
}
?>
Forgot a () for die and an = for the if statement.
Re: [PHP] $_POST['name'] [HELP]
Quote:
The more important matter is; it works. I don't care if it looks ugly. Some coding (like OOP) looks like ugly coding, but it still works. Also, I fail to see how it can cause an E_NOTICE class error when it definitely works without writing to the error log. Also, it's not slower. If anything, it's quicker as there is less coding.
I count 3-4 generic programming errors in that message.
Frayfrog is right. Many years of experience from my side, and countless discussions with the authors of PHP, proves it right.
So Jack, you're wrong. And your code is horrible, this is not VB damit :p
Re: [PHP] $_POST['name'] [HELP]
OOP ought to look better, not worse, so if you think that looks ugly you really should consider writing better code.
E_NOTICE type errors are not fatal, so they generally aren't written to the error log. Depends on your server though. Still, the same code can throw ugly errors on more strictly configured webservers.
Lastly, less coding != faster. What PHP will do with your code is first look for a defined constant by the name of your string, and only after that it will try to evaluate it as a string. This means another step, which is by definition slower.
Not many people know this but PHP has some rather intelligent string comparison optimalisations. For instance "some text" will be parsed slower than 'some text' because with double quotes it will execute some extra parsing to replace variables (ie, if you have $bla defined than "$bla" works, but '$bla' doesn't).
A good programmer knows this and uses it correctly. A bad programmer just looks at his code, shouts 'but it works!' and continues to write crappy code that will fail the next enginge update. Try not to be a bad programmer.
Re: [PHP] $_POST['name'] [HELP]
Yeah, and is concenating better than vars inside string?
'Name: '.$name.'<br>';
"Name: $name<br>";
I use single quotes all the time, because IMO concenating looks better (the code is easier to understand, for me, so I can see quickly what the piece of code is about).
"The more important matter is; it works."
Thats the worst thing you can say as a programmer. Generally, your code should look organised, should use as less memory as possible and should be efficient/fast.
Re: [PHP] $_POST['name'] [HELP]
Quote:
Originally Posted by
Daevius
Yeah, and is concenating better than vars inside string?
'Name: '.$name.'<br>';
"Name: $name<br>";
I use single quotes all the time, because IMO concenating looks better (the code is easier to understand, for me, so I can see quickly what the piece of code is about).
"The more important matter is; it works."
Thats the worst thing you can say as a programmer. Generally, your code should look organised, should use as less memory as possible and should be efficient/fast.
Pfft. How is that the WORST THING you can say as a programmer? If it works, it works. It doesn't matter if your code isn't organised. Only you will be seeing it! You don't get anything special for having an organised code, yet you do get something for making it work - which is functionality.
I agree with you on the efficiency aspect.
Now Fragfrog... I never ever clarified that I use that method of coding. I actually do code with quotes. The author of this thread used a different method, which is why I adapted my code in that way.
Re: [PHP] $_POST['name'] [HELP]
Quote:
Originally Posted by
Jackdawhouse
Pfft. How is that the WORST THING you can say as a programmer? If it works, it works. It doesn't matter if your code isn't organised. Only you will be seeing it! You don't get anything special for having an organised code, yet you do get something for making it work - which is functionality.
I agree with you on the efficiency aspect.
I actually posted 3 aspects your code should consist of:
Quote:
Originally Posted by
Daevius
Thats the worst thing you can say as a programmer. Generally, your code should look organised, should use as less memory as possible and should be efficient/fast.
I agree, organised code has no immediate influence on the result, but it helps you to code faster. And if you use CVS/SVN for a project, or it is open-source, it is very recommended that your code should be organised. And when its organised you will more quickly recognise leaks/errors, which you might havent noticed if it was total chaos.
Its not obligated, its just very recommended ;)
Re: [PHP] $_POST['name'] [HELP]
Quote:
Originally Posted by
Daevius
Its not obligated, its just very recommended ;)
Yes, fair point. Referring to this thread, this is not an open-source project.
Overall, I agree with what you and Fragfrog said and I understand where you're both coming from.
I think Superfun might have solved his problem weeks ago.
Re: [PHP] $_POST['name'] [HELP]
Quote:
Yes, fair point. Referring to this thread, this is not an open-source project.
Overall, I agree with what you and Fragfrog said and I understand where you're both coming from.
I think Superfun might have solved his problem weeks ago.
Open source is irrelevant. You'll know you're wrong, and that we're right once you ever succed to write any serious sized code.
Hint hint: 10000 lines is a SMALL project.
And allready at 10k lines ugly coding style, lack of structure and documentation it gets messed up. Nope kiddo, you CANNOT have all that in your head. And special not