Login using Javascript [on hold]











up vote
-1
down vote

favorite












I have three components to my problem.




  1. Login.html - Has an input text field and a submit button

  2. index.php - Login page with text fields for username and password, and a login button

  3. details.php - When a user successfully logs in, it displays the name of the user


So what I am trying to do is instead of the user visiting index.php and logging in, the user must open Login.html, enter his/her username and submit. I'm trying to write some code that will take the username and the default password, log the user in and display details.php. Following is the code for Login.html



<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<form action="http://127.0.0.1/index.php" onsubmit="" method="POST">
<input name="log" id="log" value=""></input>
<button id="submit" type="submit" onclick="login()">Submit</button>
</form>
<script>
function login()
{
// "user" and "password" are part of index.php
document.getElementsByName("user")[0].value = document.getElementById("log").value
document.getElementsByName("password")[0].value = "12345678"
document.forms[0].submit()
}
</script>
</body>
</html>


However, when the user submits in Login.html, it only displays index.php with the text fields populated, it does not submit and move to details.php.










share|improve this question







New contributor




Kar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by πάντα ῥεῖ, Toby Speight, t3chb0t, Sᴀᴍ Onᴇᴌᴀ, Martin R Nov 13 at 19:02


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – πάντα ῥεῖ, Toby Speight, t3chb0t, Sᴀᴍ Onᴇᴌᴀ, Martin R

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Welcome to Code Review! Unfortunately this post is off-topic for this site. Please read What topics can I ask about here? - note that it states "If you are looking for feedback on a specific working piece of code...then you are in the right place!" Also, when posting your question, there should have been text on the side that read "Your question must contain code that is already working correctly..."
    – Sᴀᴍ Onᴇᴌᴀ
    Nov 13 at 18:13

















up vote
-1
down vote

favorite












I have three components to my problem.




  1. Login.html - Has an input text field and a submit button

  2. index.php - Login page with text fields for username and password, and a login button

  3. details.php - When a user successfully logs in, it displays the name of the user


So what I am trying to do is instead of the user visiting index.php and logging in, the user must open Login.html, enter his/her username and submit. I'm trying to write some code that will take the username and the default password, log the user in and display details.php. Following is the code for Login.html



<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<form action="http://127.0.0.1/index.php" onsubmit="" method="POST">
<input name="log" id="log" value=""></input>
<button id="submit" type="submit" onclick="login()">Submit</button>
</form>
<script>
function login()
{
// "user" and "password" are part of index.php
document.getElementsByName("user")[0].value = document.getElementById("log").value
document.getElementsByName("password")[0].value = "12345678"
document.forms[0].submit()
}
</script>
</body>
</html>


However, when the user submits in Login.html, it only displays index.php with the text fields populated, it does not submit and move to details.php.










share|improve this question







New contributor




Kar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by πάντα ῥεῖ, Toby Speight, t3chb0t, Sᴀᴍ Onᴇᴌᴀ, Martin R Nov 13 at 19:02


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – πάντα ῥεῖ, Toby Speight, t3chb0t, Sᴀᴍ Onᴇᴌᴀ, Martin R

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Welcome to Code Review! Unfortunately this post is off-topic for this site. Please read What topics can I ask about here? - note that it states "If you are looking for feedback on a specific working piece of code...then you are in the right place!" Also, when posting your question, there should have been text on the side that read "Your question must contain code that is already working correctly..."
    – Sᴀᴍ Onᴇᴌᴀ
    Nov 13 at 18:13















up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have three components to my problem.




  1. Login.html - Has an input text field and a submit button

  2. index.php - Login page with text fields for username and password, and a login button

  3. details.php - When a user successfully logs in, it displays the name of the user


So what I am trying to do is instead of the user visiting index.php and logging in, the user must open Login.html, enter his/her username and submit. I'm trying to write some code that will take the username and the default password, log the user in and display details.php. Following is the code for Login.html



<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<form action="http://127.0.0.1/index.php" onsubmit="" method="POST">
<input name="log" id="log" value=""></input>
<button id="submit" type="submit" onclick="login()">Submit</button>
</form>
<script>
function login()
{
// "user" and "password" are part of index.php
document.getElementsByName("user")[0].value = document.getElementById("log").value
document.getElementsByName("password")[0].value = "12345678"
document.forms[0].submit()
}
</script>
</body>
</html>


However, when the user submits in Login.html, it only displays index.php with the text fields populated, it does not submit and move to details.php.










share|improve this question







New contributor




Kar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I have three components to my problem.




  1. Login.html - Has an input text field and a submit button

  2. index.php - Login page with text fields for username and password, and a login button

  3. details.php - When a user successfully logs in, it displays the name of the user


So what I am trying to do is instead of the user visiting index.php and logging in, the user must open Login.html, enter his/her username and submit. I'm trying to write some code that will take the username and the default password, log the user in and display details.php. Following is the code for Login.html



<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<form action="http://127.0.0.1/index.php" onsubmit="" method="POST">
<input name="log" id="log" value=""></input>
<button id="submit" type="submit" onclick="login()">Submit</button>
</form>
<script>
function login()
{
// "user" and "password" are part of index.php
document.getElementsByName("user")[0].value = document.getElementById("log").value
document.getElementsByName("password")[0].value = "12345678"
document.forms[0].submit()
}
</script>
</body>
</html>


However, when the user submits in Login.html, it only displays index.php with the text fields populated, it does not submit and move to details.php.







javascript html






share|improve this question







New contributor




Kar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Kar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Kar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 13 at 17:55









Kar

1




1




New contributor




Kar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Kar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Kar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as off-topic by πάντα ῥεῖ, Toby Speight, t3chb0t, Sᴀᴍ Onᴇᴌᴀ, Martin R Nov 13 at 19:02


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – πάντα ῥεῖ, Toby Speight, t3chb0t, Sᴀᴍ Onᴇᴌᴀ, Martin R

If this question can be reworded to fit the rules in the help center, please edit the question.




put on hold as off-topic by πάντα ῥεῖ, Toby Speight, t3chb0t, Sᴀᴍ Onᴇᴌᴀ, Martin R Nov 13 at 19:02


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – πάντα ῥεῖ, Toby Speight, t3chb0t, Sᴀᴍ Onᴇᴌᴀ, Martin R

If this question can be reworded to fit the rules in the help center, please edit the question.












  • Welcome to Code Review! Unfortunately this post is off-topic for this site. Please read What topics can I ask about here? - note that it states "If you are looking for feedback on a specific working piece of code...then you are in the right place!" Also, when posting your question, there should have been text on the side that read "Your question must contain code that is already working correctly..."
    – Sᴀᴍ Onᴇᴌᴀ
    Nov 13 at 18:13




















  • Welcome to Code Review! Unfortunately this post is off-topic for this site. Please read What topics can I ask about here? - note that it states "If you are looking for feedback on a specific working piece of code...then you are in the right place!" Also, when posting your question, there should have been text on the side that read "Your question must contain code that is already working correctly..."
    – Sᴀᴍ Onᴇᴌᴀ
    Nov 13 at 18:13


















Welcome to Code Review! Unfortunately this post is off-topic for this site. Please read What topics can I ask about here? - note that it states "If you are looking for feedback on a specific working piece of code...then you are in the right place!" Also, when posting your question, there should have been text on the side that read "Your question must contain code that is already working correctly..."
– Sᴀᴍ Onᴇᴌᴀ
Nov 13 at 18:13






Welcome to Code Review! Unfortunately this post is off-topic for this site. Please read What topics can I ask about here? - note that it states "If you are looking for feedback on a specific working piece of code...then you are in the right place!" Also, when posting your question, there should have been text on the side that read "Your question must contain code that is already working correctly..."
– Sᴀᴍ Onᴇᴌᴀ
Nov 13 at 18:13

















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

List directoties down one level, excluding some named directories and files

list processes belonging to a network namespace

List all connected SSH sessions?