MH90 Posted March 2, 2020 Share Posted March 2, 2020 I am totally new in PHP, can anyone help me with this problem: Login Button is not working after clicking this button this should print a echo message. <from action="" method="POST"> <input type="text" placeholder="username"> <br> <input type="password" placeholder="Password"><br> <input type="submit" name="login" value="Login"> </from> <?php if ( isset($_POST['login'])){ echo "hissssssssssssssssssss"; } ?> Quote Link to comment Share on other sites More sharing options...
benanamen Posted March 2, 2020 Share Posted March 2, 2020 There is no such thing as a "from" tag. 1 Quote Link to comment Share on other sites More sharing options...
MH90 Posted March 2, 2020 Author Share Posted March 2, 2020 @benanamen thanks for your reply Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 2, 2020 Share Posted March 2, 2020 Plus - your script is confused as to where it is. You begin by outputting your form (with problems) and then you ask if the POST has been created. Obviously it has not so you won't see any echo there. The PHP code should always be at the beginning of your scripts and your html at the end after all of your logic has had a chance to execute. In your case if no POST has been received yet then you need to send out the blank form and exit. If it has, that's when you check what has been sent back and send out your echos or whatever results you generate and then exit. 1 Quote Link to comment Share on other sites More sharing options...
Barand Posted March 2, 2020 Share Posted March 2, 2020 Input fields also work better when they have "name" attributes 1 Quote Link to comment Share on other sites More sharing options...
NotSunfighter Posted March 3, 2020 Share Posted March 3, 2020 Horrible coding practice to use a placeholder in place of a <label>. 1 Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 3, 2020 Share Posted March 3, 2020 I think we lost the OP.... Quote Link to comment Share on other sites More sharing options...
Psycho Posted March 3, 2020 Share Posted March 3, 2020 7 hours ago, NotSunfighter said: Horrible coding practice to use a placeholder in place of a <label>. Not "horrible". There are use cases where that makes more sense than labels. E.g. when designing a form for a mobile device where screen real estate comes at a premium. Quote Link to comment Share on other sites More sharing options...
NotSunfighter Posted March 4, 2020 Share Posted March 4, 2020 21 hours ago, Psycho said: Not "horrible". There are use cases where that makes more sense than labels. E.g. when designing a form for a mobile device where screen real estate comes at a premium. This is an example of LABEL with INPUT. Works down to 175px width. At this point a keyboard for input is useless. The placeholder attribute was to be a 'hint'. You give a book a title like The Long Kiss Goodnight" and a hint like P. Eye story <!DOCTYPE html> <html lang="en"> <head> <style> #find-search { background: #3a658e; padding-left: 10px; border-radius: 3px; cursor: pointer; margin-left: 5px; color:white; } #find-search:hover { background-color: #399edc } #quickfind{ font-size: smaller; } </style> </head> <body> <form action="/quickfind" id="quickfind" method="post" name="quickfind"> <label for="find-search">Quick Search</label> <input type="text" id="find-search" placeholder="Keywords"> </form> </body> </html> I'd rely on placeholders in situations like this: <!DOCTYPE html> <html lang="en"> <head> <style> #find-search { background: #3a658e; padding-left: 10px; border-radius: 3px; cursor: pointer; color:white; } #find-search:hover { background-color: #399edc } </style> </head> <body> <form action="/quickfind" id="quickfind" method="post" name="quickfind"> <label>Enter your name</label><br> <input type="text" id="find-search" placeholder="First name"><br> <input type="text" id="find-search" placeholder="Last Name"> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted March 4, 2020 Share Posted March 4, 2020 (edited) Placeholders, by themselves, will make the form less accessible for people with certain disabilities. More information can be found here:https://webaim.org/techniques/forms/advanced 54 minutes ago, NotSunfighter said: I'd rely on placeholders in situations like this: Be aware that the <label> tag isn't doing anything here: <form action="/quickfind" id="quickfind" method="post" name="quickfind"> <label>Enter your name</label><br> <input type="text" id="find-search" placeholder="First name"><br> <input type="text" id="find-search" placeholder="Last Name"> </form> It needs to be connected to an <input> tag using the "for" attribute...or the label and corresponding <input> tag need to be enclosed with open/close <label> tags. Also, I'm fairly certain a <label> tag cannot be connected with two separate input fields. Each of the <input> tags above need their own label. More information can be found here:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label FYI - There is an easy way to tell if a label is connected with an input field. Clicking the label in your browser should place focus on the corresponding input field. Edited March 4, 2020 by cyberRobot Added last line Quote Link to comment Share on other sites More sharing options...
NotSunfighter Posted March 5, 2020 Share Posted March 5, 2020 I know. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.