Jump to content

PHP Login button not working


MH90

Recommended Posts

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"; 

} 

?>

 

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>
	

 

Link to comment
Share on other sites

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 by cyberRobot
Added last line
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.