I use indentation to check out the form; missing brace at end?  Check it
out.

<?php
    $usersfile = "users.php";
    session_start();
    session_register("user","pass");
    if(isset($user)) $username = $user;
    if(isset($pass)) $password = $pass;
    if(!$username) {
?>
     <form>
      User : <input type="text" name="username"><br>
      Password : <input type="password" name="password"><br>
      <input type="submit" value="Login">
     </form>
<?php
    } else {
        $user = $username;
        $pass = $password;
        $userslist = file($usersfile);
        for($i = 1; $i < sizeof($userslist); $i++) {
            $userline = explode("||||||", $userslist[$i]);
            if($usersline[0] == $username) {
                if($password != rtrim($usersline[1])) {
                    die("Incorrect Username");
                } else {
                    $i = sizeof($userslist) + 1;
                }
            }
        }
        if(!$action) $action = "main";
        switch($action) {
            case "main":
?>
     <a href="?action=post">Post News</a><br>
     <a href="?action=edit">Edit News</a><br>
     <a href="?action=delete">Delete News</a><br>
     <a href="?action=adduser">Add User Account</a><br>
     <a href="?action=deluser">Delete User</a>
<?php
                break;
            case "adduser":
?>
       <form>
           <input type="hidden" name="action" value="process">
           <input type="hidden" name="process" value="adduser">
           Username : <input type="text" name="uname"><br>
           Password : <input type="password" name="pword"><br>
           <input type="submit" value="Add User">
        </form>
<?php
                break;
            case "deleteuser":
                $userslist = file($usersfile);
                for($i = 0; $i < sizeof($userslist); $i++) {
                    $userline = explode("||||||", $userslist[$i]);
                    echo "<a href=\"?action=process&process=deluser&uname=";
                    echo $userline[0].">".$userline[0]."</a><br>";
                }
                break;
            case "post":
?>
       <form>
           <input type="hidden" name="action" value="process">
           <input type="hidden" name="process" value="post">
           Title : <input type="text" name="title"><br>
           <textarea name="text"></textarea><br>
           <input type="submit" value="Post">
       </form>
<?php
                break;
            case "edit":
                $dir = dir("./news");
                while($file=$dir->read()) {
                    if(is_file("./news/".$file)) {
                        $name = str_replace(".txt", "", $file);
                        echo "<a href=\"?action=process&process=view&news=";
                        echo $file."\">".$name."</a>";
                    }
                }
                $dir->close();
                break;
            case "delete":
                $dir = dir("./news");
                while($file=$dir->read()) {
                    if(is_file("./news/".$file)) {
                        $name = str_replace(".txt", "", $file);
                        echo "<a href=\"?action=process&process=confim&news=";
                        echo $file."\">".$name."</a>";
                    }
                }
                $dir->close();
                break;
            case "process":
                switch($process) {
                    case "adduser":
                        $fp = fopen($usersfile, "w");
                        for($i = 0; $i < sizeof($userslist); $i++)
                            fwrite($fp, $userslist[$i]);
                        fwrite($fp, "\r\n".$uname."||||||".$pword);
                        fclose($fp);
                        echo "<b>User Added!</b>";
                        break;
                    case "deluser":
                        $fp = fopen($usersfile, "w");
                        for($i = 0; $i < sizeof($userslist); $i++) {
                            $userdetails = explode("||||||", $userslist[$i]);
                            if($userdetails[0] != $uname)
                                fwrite($fp, $userslist[$i]);
                        }
                        fclose($fp);
                        echo "<b>User Deleted!</b>";
                        break;
                    case "post":
                        $fp = fopen("./news".$title.".txt", "w");
                        fwrite($fp, $title."\r\n");
                        fwrite($fp, $text);
                        echo "<b>News Posted!</b>";
                        break;
                    case "view":
                        $newsdata = file("./news/".$news);
                        $title = rtrim($newsdata[0]);
                        echo "Title: <b>".$title."</b>"
?>
       <br>
       <form>
        <input type="hidden" name="process" value="post">
        <input type="hidden" name="action" value="process">
        <input type="hidden" name="tittle" value="<?php echo $tittle; ?>">
           <textarea name="text">
<?php
                        for($i = 1; $i < sizeof($newsdata); $i++) {
                            echo $newsdata[$i];
                        }
?>
        </textarea>
        <input type="submit" value="Edit">
       </form>
<?php
                        break;
                    case "confirm":
?>
       <form>
          <input type="hidden" name="process" value="complete">
            <input type="hidden" name="action" value="process">
          <input type="hidden" name="news" value="<?php echo $news; ?>">
             <b>Are you Sure?</b><br>
           <input type="submit" value="Yes">
       </form>
       <form>
           <input type="submit" value="No">
       </form>
<?php
                        break;
                    case "complete":
                        unlink("./news/".$news);
                        echo "Don't Blame me, you Clicked Yes!";
                        break;
                }
        }
    }                   //<==== missing } closes off else
                        // related to if(!$username) above
?>

-----Original Message-----
From: scott [gts] [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 02, 2001 10:38 AM
To: php
Subject: RE: [PHP] Can any one spot the Parse error Here


confucious say:

typing it up in 20 minutes and then spending 2 hours
debugging is much worse than taking an hour to type it
up and spending only 20 minutes debugging ;)

> -----Original Message-----
> From: ReDucTor [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 02, 2001 3:31 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Can any one spot the Parse error Here
>
>
> Only typed it up in like 20 min, i normaly do that after :)
> ----- Original Message -----
> From: Andrew Halliday <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, July 02, 2001 5:26 PM
> Subject: Re: [PHP] Can any one spot the Parse error Here
>
>
> > Brace count mismatch.
> > You are missing a '}'.
> > God knows where it is...inconsistent spacing and code too lengthy.
> > Functionise/objectise your code!
> >
> > AndrewH
> >
> > ----- Original Message -----
> > From: "ReDucTor" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Monday, July 02, 2001 4:17 PM
> > Subject: [PHP] Can any one spot the Parse error Here
> >
> >
> > > Hey,
> > >     Right at the end i get a prase error, which i figure i have missed
a
> > > break; or a }
> > > but i just can't seem to find it, can some one look thro it, tell me
if
> > they
> > > spot it?
> > >
> > > My Code:
> > > ========================================================
> > > <?php
> > >    $usersfile = "users.php";
> > >    session_start();
> > >    session_register("user","pass");
> > >    if(isset($user))
> > >    $username = $user;
> > >    if(isset($pass))
> > >    $password = $pass;
> > >    if(!$username)
> > >    {
> > >     ?>
> > >     <form>
> > >      User : <input type="text" name="username"><br>
> > >      Password : <input type="password" name="password"><br>
> > >      <input type="submit" value="Login">
> > >     </form>
> > >     <?php
> > >    }
> > >    else
> > >    {
> > >     $user = $username;
> > >     $pass = $password;
> > >     $userslist = file($usersfile);
> > >     for($i = 1; $i < sizeof($userslist); $i++)
> > >     {
> > >      $userline = explode("||||||", $userslist[$i]);
> > >      if($usersline[0] == $username)
> > >      {
> > >       if($password != rtrim($usersline[1]))
> > >       {
> > >        die("Incorrect Username");
> > >       }
> > >       else
> > >       {
> > >        $i = sizeof($userslist) + 1;
> > >       }
> > >      }
> > >     }
> > >     if(!$action)
> > >      $action = "main";
> > >     switch($action){
> > >      case "main":
> > >     ?>
> > >     <a href="?action=post">Post News</a><br>
> > >     <a href="?action=edit">Edit News</a><br>
> > >     <a href="?action=delete">Delete News</a><br>
> > >           <a href="?action=adduser">Add User Account</a><br>
> > >           <a href="?action=deluser">Delete User</a>
> > >           <?php
> > >        break;
> > >         case "adduser":
> > >        ?>
> > >       <form>
> > >           <input type="hidden" name="action" value="process">
> > >           <input type="hidden" name="process" value="adduser">
> > >           Username : <input type="text" name="uname"><br>
> > >           Password : <input type="password" name="pword"><br>
> > >           <input type="submit" value="Add User">
> > >        </form>
> > >       <?php
> > >       break;
> > >      case "deleteuser":
> > >       $userslist = file($usersfile);
> > >          for($i = 0; $i < sizeof($userslist); $i++)
> > >             {
> > >        $userline = explode("||||||", $userslist[$i]);
> > >        echo "<a href=\"?action=process&process=deluser&uname=";
> > >        echo $userline[0].">".$userline[0]."</a><br>";
> > >       }
> > >       break;
> > >      case "post":
> > >       ?>
> > >       <form>
> > >           <input type="hidden" name="action" value="process">
> > >           <input type="hidden" name="process" value="post">
> > >           Title : <input type="text" name="title"><br>
> > >           <textarea name="text"></textarea><br>
> > >           <input type="submit" value="Post">
> > >       </form>
> > >       <?php
> > >       break;
> > >       case "edit":
> > >            $dir = dir("./news");
> > >       while($file=$dir->read())
> > >                {
> > >        if(is_file("./news/".$file))
> > >        {
> > >       $name = str_replace(".txt", "", $file);
> > >       echo "<a href=\"?action=process&process=view&news=";
> > >       echo $file."\">".$name."</a>";
> > >        }
> > >       }
> > >       $dir->close();
> > >       break;
> > >    case "delete":
> > >          $dir = dir("./news");
> > >       while($file=$dir->read())
> > >                {
> > >       if(is_file("./news/".$file))
> > >       {
> > >       $name = str_replace(".txt", "", $file);
> > >       echo "<a href=\"?action=process&process=confim&news=";
> > >       echo $file."\">".$name."</a>";
> > >       }
> > >       }
> > >       $dir->close();
> > >       break;
> > >    case "process":
> > >       switch($process){
> > >         case "adduser":
> > >       $fp = fopen($usersfile, "w");
> > >                for($i = 0; $i < sizeof($userslist); $i++)
> > >        fwrite($fp, $userslist[$i]);
> > >       fwrite($fp, "\r\n".$uname."||||||".$pword);
> > >       fclose($fp);
> > >       echo "<b>User Added!</b>";
> > >       break;
> > >      case "deluser":
> > >       $fp = fopen($usersfile, "w");
> > >                for($i = 0; $i < sizeof($userslist); $i++)
> > >                      {
> > >        $userdetails = explode("||||||", $userslist[$i]);
> > >        if($userdetails[0] != $uname)
> > >        fwrite($fp, $userslist[$i]);
> > >       }
> > >       fclose($fp);
> > >       echo "<b>User Deleted!</b>";
> > >       break;
> > >      case "post":
> > >       $fp = fopen("./news".$title.".txt", "w");
> > >             fwrite($fp, $title."\r\n");
> > >       fwrite($fp, $text);
> > >       echo "<b>News Posted!</b>";
> > >       break;
> > >      case "view":
> > >       $newsdata = file("./news/".$news);
> > >          $title = rtrim($newsdata[0]);
> > >       echo "Title: <b>".$title."</b>"?>
> > >       <br>
> > >       <form>
> > >        <input type="hidden" name="process" value="post">
> > >        <input type="hidden" name="action" value="process">
> > >        <input type="hidden" name="tittle" value="<?php
> > >                                              echo $tittle; ?>">
> > >           <textarea name="text">
> > >        <?php
> > >         for($i = 1; $i < sizeof($newsdata); $i++)
> > >         {
> > >            echo $newsdata[$i];
> > >         }
> > >        ?>
> > >        </textarea>
> > >        <input type="submit" value="Edit">
> > >       </form>
> > >       <?php
> > >       break;
> > >      case "confirm":
> > >       ?>
> > >       <form>
> > >          <input type="hidden" name="process" value="complete">
> > >            <input type="hidden" name="action" value="process">
> > >          <input type="hidden" name="news" value="<?php
> > >                                                    echo $news; ?>">
> > >             <b>Are you Sure?</b><br>
> > >           <input type="submit" value="Yes">
> > >       </form>
> > >       <form>
> > >           <input type="submit" value="No">
> > >       </form>
> > >       <?php
> > >       break;
> > >      case "complete":
> > >          unlink("./news/".$news);
> > >          echo "Don't Blame me, you Clicked Yes!";
> > >         break;
> > >    }
> > >     }
> > > ?>
> > > ========================================================
> > > I should test it every step, insted of just typing it up, then testing
> it
> > > after...
> > >    - James "ReDucTor" Mitchell
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > To contact the list administrators, e-mail:
[EMAIL PROTECTED]
> > >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to