Jump to content

sessions/forms


speedy33417

Recommended Posts

First time posting here. New to php. ;D

I'm trying to use sessions for an html form to process user ID and password.
index.php receives two variables that need to be global variables which will be carried over to loggedin.php and verified either invalid user id and/or password or access to that page.

My problem is the first half: index.php

This is what I have so far:

[code]
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css" href="inc/theme.css">
</head>

<body leftmargin="0" rightmargin="0" bottommargin="0" topmargin="0" marginheight="0" marginwidth="0">

  <form name="logForm" action="loggedin.php">
    <div align="center">
      <table border="0" width="610" cellpadding="0" cellspacing="0">
        <tr>
          <td width="105" valign="top"><span class="text1">&nbsp;user ID</span></td>
          <td width="105" valign="top"><span class="text1">&nbsp;password</span></td>
          <td width="400"></td>
        </tr>
        <tr>
          <td width="105" valign="top"><input name="userId" class="form3"></td>
          <td width="105" valign="top"><input name="passWord" class="form3"></td>
          <td width="400" valign="bottom"><a href="javascript:if(document.logForm.onsubmit())document.logForm.submit()" class="text1">Log in</a></td>
        </tr>
      </table>
    </div>
  </form>
         
</body>

</html>
[/code]

I need help inserting the session for those variables so after submitting, they can be called with a session_start on loggedin.php.
Link to comment
Share on other sites

All I see is some HTML.  Are you trying to verify the user on the same page or are you passing it to another page?  I'm kind of confused as to where you're going with this.  From what I get you're trying to have verify a user but I didn't see any code that indicates anything but displaying a form = /
Link to comment
Share on other sites

I was going to get it verified on the next page, but now that you ask me is it possible to do it on the same page?

But getting back to the way I wanted to do it. I hear about all these super globals at what not. I wanted to make sure that my first page is all done before I worry about the second one.
Do I need to start a session on index.php or it's good as is?
Link to comment
Share on other sites

Yea, its possible to do it on the same page, just have to put the form and the variables above the actual php code else you'll get an error since the user hasn't given any info yet. I recommend you start a session at the top of all your pages since you are going to be using sessions. That way, if someone is already logged in, you can have the page display somtehing else besides letting him signup again.
ex:
<?php session_start(); ?>
<html>
etc
</html>
Link to comment
Share on other sites

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.