Jump to content

Confusing web page! Calls different forms . . a little weird


Recommended Posts

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?
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
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.
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!!
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.