I’ll have one ready for by tomorrow. I don’t have access to my server away from my computer.
I am making one right now, it doesn’t really matter that its on my server, if you run the examples I will show.
Guys, we’ve explained this over and over again, not just in this thread. Either you learn and write better code, or you don’t. We can’t do that for you.
Like I said, I completely understand that it’s hard to give up a beloved quirk. When I started PHP, I used the exact same technique you use today, because that was simply all I knew. The difference is: While you were busy talking about your government systems, I kept learning and listening.
I don’t care if your code runs on a single PC in your basement or on over 9,000 serious-business government machines. If it’s good, I’ll applaud you for it and learn from you. If it’s crap, then it’s crap. I care about code, and you should too.
Well, yes, crap code is just that! We do not disagree with that comment.
But, how has all this ranting helped the OP? You say his code is crap, but, do not help him.
Since the four or five of us have “Hyjacked” his thread, he stopped posting… Did anyone notice?
With one major difference, you keep spouting that the technique is crap without anything, other than you, proving otherwise. I disputed your claims of “Major frameworks don’t do this.” I am not blustering with my credentials, I am showing that I work in an area where the code matters.
I learn as I go as well, you have to in this industry. I DO have issue when someone arbitrarily spouts information as though it were fact with out substantiating it from reputable sources.
As far as the OP, they were a guest. This was a single post and go.
Grats, [member=43746]ErnieAlex[/member] on his 100th Karma
I modified the language on a few of the posts, we’re all friends here. Just be respectful towards each other.
Nothing wrong with a good debate about coding practices, that’s what forums are for.
Thanks PHPhelp/Topcoder! Love this site and love all the info from all…
Astonecipher, PhDs, “reputable sources” and “million-dollar government systems” are not always accurate and not always the best way to do things.
It’s better to think for yourself, formulate and validate your own conclusions, then rely on those of others.
Modified - TopCoder - Just keeping it civil
*Modified* - TopCoder - Just keeping it civil
Aww, [member=69011]Topcoder[/member], It was just starting to get exciting around here. I was just getting ready to start selling tickets.
To save us all a lot of time, lets just assume I am never wrong. ;D
I am. That’s why I don’t believe you. I’ve proven it is still in use by frameworks that you said didn’t use it. You still have yet to give anything other than conjecture.
Administrator: If you want to participate in this discussion, write your own posts. If you want to delete all posts which you feel aren’t politically correct enough, delete them. But do not ever put words in my mouth.
This is a normal discussion between grown-ups, and none of us needs a nanny.
[member=72272]astonecipher[/member]: I cannot fix your attitude. Kevin and I have patiently explained every single technical aspect ad nauseam. Turn your brain on, think about it, and I’m sure you’ll come to the right conclusions. I think you’re actually a smart guy. But right now, you’re just wasting everybody’s time.
Might this just be a misunderstanding?
What you supplied above is a snippet of a form builder where they change a forms submit button label.
As I read it Pretty Homey here are talking about validating the request method using isset($_POST[‘submit’]), not actually having a submit button -which indeed is very common.
I might be mistaken though, if so - back to the popcorn I guess.
There is a fine line to walk and I understand that. Sometimes the way things are written comes off as mean and offensive to other. Little jabs here and there. I just removed the little jabs that stir emotion in everyone posts. The posts don’t deserve deletion, just a little rewording is all. Everyone has really good strong opinions and there is nothing wrong with that and I’m the last person that wants to censor anything.
Debate Away, I’m actually looking forward to seeing the examples and learning from it.
Just saw this. The IE<9 issue is only ONE reason not to use it. There are others.
[member=71845]JimL[/member], the root discussion is isset($_POST[‘submit’]) VS if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’)
According to this https://www.netmarketshare.com/browser-market-share.aspx?qprid=2&qpcustomd=0, IE8 is in higher use than IE9. How ever many thousands that translates to is how many users you will knowingly cause a failure for if they use your site when you can easily not.
What is the issue with my attitude? Dislike being called out when you STILL have not substantiated your claim? What you have patiently done, is to reverberate what you have been saying without anything other than personal opinion. Then launched personal attacks thinking it will do something. I know I am an asshole, I also will back down when proven incorrect, key word there, proven. You saying whatever is not proof.
I understand what you are saying and it is valid, HOWEVER, checking the value of a button is not incorrect.
With that, I’m done. You are not willing to provide any thing for your case on the topic, and “cause I said so” doesn’t count.
[member=46186]Kevin Rubio[/member]
Should it be:
[php]if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’)[/php]
or
[php]if ($_SERVER[‘REQUEST_METHOD’] === ‘POST’)[/php]
Topcoder: usually you want equals and not “kinda equals”.
Though in most frameworks you have shorter helpers for these actions
Zend
[php]if ($request->isPost()) {
// …
}[/php]
Symfony
[php]if ($request->isMethod(‘POST’)) {
// …
}[/php]
Laravel
[php]if (Request::isMethod(‘post’)) {
// …
}[/php]
And of course, with a proper router you can route to different controller methods depending on which request method is used.
Ok boys, here is a VERY basic example showing problem using curl.
b.php uses if (isset($_POST[‘submit’]))
d.php uses if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’)
One works, one doesn’t.
Files (Source Code Shows):
http://galaxyinternet.us/post/a.php
http://galaxyinternet.us/post/b.php
http://galaxyinternet.us/post/c.php
http://galaxyinternet.us/post/d.php
a.php (curl) posts to b.php
c.php (curl) posts to d.php
EDIT*: FYI: You can run the curl code from your own server and post to my server. It doesn’t matter where it comes from. You are effectively bypassing my login form (if I had one up).
[member=46186]Kevin Rubio[/member] Ajax fails as well, no? I don’t think this will post the submit button, no chance to test now though.
[code]
[/code][hr]
- Readability, checking against request method is much clearer than checking against some form field
[hr]
- Decoupling, when checking the name of the submit button you get a tight couple between controller and view.