Solarpitch Posted January 11, 2007 Share Posted January 11, 2007 Hey Guys,Has anyone ever come across a web page that when you select submit on one form, it calls the other!! :o(eg:First form on page:[code] if (isset($_SESSION['valid_user'])) { echo 'You are logged in as '.$_SESSION['valid_user'].' '.' | '.'<a href="logout.php">Log out</a>'; } else { if (isset($username)) { // if they've tried and failed to log in echo 'Incorrect username or password! '.' | '.'<a href='.$_SESSION['last_page'].'>Try Again</a>'; } else { echo '<form name="form1" method="post" action="process_login.php">'; echo '<input type="text" name="username" id="menu_textbox">'; echo '<input type="password" name="password" id="menu_textbox">'; echo '<input type="submit" name="Submit" value="Login>>" id="menu_textbox">'; }[/code]Second form on page:[code] <form name="form1" method="post" action="send_mail.php"> <p>Email: <input name="email" type="text" id="email"> </p> <p>Subject: <input name="subject" type="text" id="subject"> </p> <p>Message:</p> <p> <textarea name="message" id="message"></textarea> </p> <p> <input type="submit" name="Submit" value="Submit"></p> </form>[/code]If submit is clicked in the second form, the first form is called. ie . . so it executes the process_login page. I know this is a bit confusing, but if any one could shed some light on it? Quote Link to comment https://forums.phpfreaks.com/topic/33791-confusing-web-page-calls-different-forms-a-little-weird/ Share on other sites More sharing options...
micah1701 Posted January 11, 2007 Share Posted January 11, 2007 both your forms are named "form1" that probably has something to do with it.I think this is more of an HTML issue then PHP Quote Link to comment https://forums.phpfreaks.com/topic/33791-confusing-web-page-calls-different-forms-a-little-weird/#findComment-158488 Share on other sites More sharing options...
Daniel0 Posted January 11, 2007 Share Posted January 11, 2007 Also, you cannot do this: [code]<input type="submit" name="Submit" value="Login>>" id="menu_textbox">[/code]You cannot have the > signs in there, you have to encode them to > Quote Link to comment https://forums.phpfreaks.com/topic/33791-confusing-web-page-calls-different-forms-a-little-weird/#findComment-158491 Share on other sites More sharing options...
Solarpitch Posted January 11, 2007 Author Share Posted January 11, 2007 Hey thanks for the advise guys but neither work. I should mention that when session['valid_user']; is set . . ie: the user is looged in, it seems to work perfect!! Just happens when the user is not logged in Quote Link to comment https://forums.phpfreaks.com/topic/33791-confusing-web-page-calls-different-forms-a-little-weird/#findComment-158495 Share on other sites More sharing options...
Daniel0 Posted January 11, 2007 Share Posted January 11, 2007 Hmm... I probably should have mentioned that the thing I pointed out probably didn't cause the error.I think I found the error though. When $_SESSION['valid_user'] is not set the other form is echoed, but that form doesn't close. You need echo the [tt]</form>[/tt] tag as well. Quote Link to comment https://forums.phpfreaks.com/topic/33791-confusing-web-page-calls-different-forms-a-little-weird/#findComment-158500 Share on other sites More sharing options...
Solarpitch Posted January 11, 2007 Author Share Posted January 11, 2007 Ok, I changed it to this[code] echo '<form name="form1" method="post" action="process_login.php">'; echo '<input type="text" name="username" id="menu_textbox">'; echo '<input type="password" name="password" id="menu_textbox">'; echo '<input type="submit" name="Submit" value="Login" id="menu_textbox">'; echo '</form>';[/code]and I am still having the problem! Hate code!! Quote Link to comment https://forums.phpfreaks.com/topic/33791-confusing-web-page-calls-different-forms-a-little-weird/#findComment-158516 Share on other sites More sharing options...
Solarpitch Posted January 11, 2007 Author Share Posted January 11, 2007 Hey guys, I fixed it. That worked . . I just had to update it on 2 pages! Thanks for the help, much appriciated! Quote Link to comment https://forums.phpfreaks.com/topic/33791-confusing-web-page-calls-different-forms-a-little-weird/#findComment-158518 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.