1
Good people I have a problem with my code I have 2 photons in which one logs in and the other does the Register, I’m using a one page template, and I’m having some problems. I when I do the Register everything is ok without problems, the problem is when I log in. I’m using 3 files for each thing, one that has html which is where the code of both Forms is, I have 1 to connect the BD which is what I’m using for the 2 as well, and I have another to connect the table and ask for the data I need, each having their own. At the beginning of each form in html I am asking for the proper file information being the login login.php as you can see in the code below.
<script language="javascript">
function submitform()
{
document.forms["as"].submit();
}
</script>
<form name="as" method="POST" action="loginpro.php">
Username: <input type="text" name="username" /><br /><br />
Password: <input type="password" name="password" /><br /><br />
<input style="font-size: 17px" type=button onClick="submitform()" value="Submit"/>
</form>
My problem is that when I try to log in it doesn’t try to use loginpro.php but regpro.php which is the file I use for Register as you can also see in the code below.
<script language="javascript">
function submitform()
{
document.forms["register"].submit();
}
</script>
<center>
<form name="register" method="POST" action="regpro.php">
Username: <input type="text" name="username" /><br /><br />
Email: <input type="text" name="Email" /><br /><br />
First Name: <input type="text" name="fname" /><br /><br />
Last Name: <input type="text" name="lname" /><br /><br />
Password: <input type="password" name="password" /><br /><br />
<input style="font-size: 11px" type=button onClick="submitform()" value="Submit"/>
</form>
If you can help me I’m very hurt because I need this done with some urgency.
Why, its function
submitform()
is being used for both Forms. And it gives the Submit in the same form always. You must use a function for each form or pass a parameter telling which of the Forms should be submited.– Franchesco
Why do you use javascript if you can just use one
<input type="submit">
? The way it is there, it’s the same... because you’re not adding anything to Submit...– Rafael Withoeft
@Rafaelwithoeft I tried with this code and it was working but the template my client asked me to use does not allow sending without java.
– Pedro Pimenta
@Earendul I’m using a submitform() for each I forgot to copy the JS code to register it.
– Pedro Pimenta
Then edit your question and put the code you forgot, ;)
– Franchesco
Try to change your function to receive parameters, so I believe you are always overwriting the same function and so should generate this problem.
– Rafael Withoeft
@Earendul done ,I’m new in web programming so it’s normal if I make a few mistakes but I appreciate the help
– Pedro Pimenta
@Can you give me an idea of how I can do it please.
– Pedro Pimenta
I don’t know if it’s gonna work, but.... try changing your input to type="Submit" and put the event in the form so onsubmit="submitform(this)"; End result would look something like this:
<script>
 function formsubmit(form) {
 form.submit();
 }
</script>
<form action="#" method="post" onsubmit="formsubmit(this)">
 <input type="submit" value="Enviar">
</form>
– Rafael Withoeft
@Rafaelwithoeft Thank you already this everything to work thanks to you very much.
– Pedro Pimenta