0

I'm trying to create a login page, with a simple form consisting of a Username, Password and Submit Button. The data from the two textfields needs to be sent to the separate PHP file so that it can query my oracle database for their validity (this bit already works with dummy data).

I'm using POST on the form, but not only is the PHP file not receiving any data, when I use code I've found online to dump the contents of the POST, the HTML file isn't even generating any.

The HTML code is as follows:

<html>    
  <form action="login.php" method="POST">

   <input type="text" 
        placeholder="Username:"
        name:"username"
        required
        autofocus>  

   <input type="password"   
        placeholder="Password:"
        name:"userpwd"
        required> 

   <input type="submit" 
        value="LOG IN">  

  </form>
</html>

And the relevant PHP code I'm using to test the POST:

 <?php     
   $username = htmlspecialchars($_POST['username']);
   $password = htmlspecialchars($_POST['userpwd']);

   $msg = "Username:" . $username . "\nPassword:" . $password;
   echo nl2br($msg);
 ?>

Nothing I've found anywhere has worked, so I'm coming here to (hopefully) find out its some silly mistake I've made and easily fixable. Cheers.

2
  • Possible duplicate of PHP Contact Form not submitting Commented Apr 16, 2016 at 12:23
  • 3
    Use name= instead of name:, do the same for password Commented Apr 16, 2016 at 12:24

3 Answers 3

1

The error happens because you are using : instead of = after name

<input type="text" placeholder="Username:" name="username" required autofocus> 
<input type="password" placeholder="Password:" name="userpwd" required> 
Sign up to request clarification or add additional context in comments.

1 Comment

AAaaaaannnndddd, that's it. I even checked for that but got tripped up looking at the Username: bit and thinking it was fine. Cheers, extra set of eyes helped a lot there.
0

replace : with = in your input field after name attribute

<input type="text" placeholder="Username:" name="username" required autofocus>

<input type="password" placeholder="Password:" name="userpwd" required> 

Comments

0

You are using colon(:) for value of "name" attribute. Replace colon(:) with equalto(=) like below.

    <input type="text" 
        placeholder="Username:"
        name="username"
        required
        autofocus>  

   <input type="password"   
        placeholder="Password:"
        name:"userpwd"
        required> 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.