SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    "Warning: Page has Expired" and sessions

    I've worked myself through Kevin Yanks article Managing Users with PHP Sessions and MySQL.

    The problem is when I'm going to register/signup a new user. If I forget a field I get an message (by JavaScript and the alert() function) telling me to fill them in properly. Everything ok so far.

    The problem is when i click 'OK' on this alert to return to the signupform. Then the site as expired and the browser tells me it is a 'security precaution' done by Internet Explorer.

    Is there a workaround to this problem?

    -Helge

  2. #2
    SitePoint Zealot amit290's Avatar
    Join Date
    Oct 2001
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would it be easier to validate the fields after sending the form?

    i.e.

    PHP Code:
    if ((empty($field1)) OR (empty($field2)))
      {
      echo (
    "some error message here");
      }
      
      
    //else do something with the form .. like email it
      
    else {
            
    mail ("abc@a.com""form""$field1 $field2");

    something like that anyway

    EDITED BIT====

    BTW I've always validated after sending because I h8 using JavaScript. Maybe some1 else knows what a solution to your problem is, but hopefully the above gives you another option for validation.
    Last edited by amit290; Jan 29, 2002 at 09:57.

  3. #3
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I understand what you mean, but as far as I an see I do the validation after the form is sent.
    Here is the relevant code:
    PHP Code:
    <?php //signup.php
    //The error-function
    function error($msg) {
        
    ?>
        <html>
        <head>
        <script language="JavaScript">

        alert("<? echo $msg?>");
        history.back();

        </script>
        </head>
        <body>
        </body>
        </html>
        <?php
        
    exit();
    // END function error($msg)

    //----------------------

    if(!isset($submit)): // Shows signupform
    ?>
    <html>
    <head>
    <title>Signup.php</title>
    </head>
    <body>
    <h1>Sign Up</h1>
    <form method=post action="<?=$PHP_SELF?>">
    <p>UserId: <input name="newuserid" type=text maxlength=100 size=25></p>
    <p>Name:   <input name="newname" type=text maxlength=100 size=25></p>
    <p>Email:  <input name="newemail" type=text maxlength=100 size=25></p>
    <p>Other Notes<textarea wrap name="newnothes" rows=5 cols=30></textarea></p>
    <p><input type=submit name="submit" value="OK">
    </form>
    </body>
    </html>


    <?php
    else: //Process the form

    // This is were the problems is
    if(empty($_POST[newuserid]) or empty($_POST[newname]) or empty($_POST[newemail])) {
        
    error("One ore more fields were left blank. Please fill them in.");
        }

    // More PHP-code like MYSQL INSERT etc... 
    // Works fine when I type all the required information into the form

    endif;
    ?>
    Does anyone see what I'm doing wrong??

    -Helge
    Last edited by Helge; Jan 29, 2002 at 10:48.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •