Location: PHPKode > projects > MyTodos > signup-ctrl.php
<?
###################################################
#Copyright (C) 2002 Lihua Gao (hide@address.com) 
#
#$Id: signup-ctrl.php,v 1.1 2002/12/05 10:03:33 gaolihua Exp $
#
#This file is part of myTodos.
#
#myTodos is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#myTodos is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with myTodos; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#####################################################
?>
<?
   session_start();
   require_once("config.php");


   if (isset($useremail) && isset($password))
   {
      $sql = "insert into users (usr_password, usr_email, usr_createdate) values(";
      $sql .= "'".$password."', ";
      $sql .= "'".$useremail."', curdate() )";

      //echo "sql: ".$sql."<br>";

      $result = mysql_query($sql);
      if ($result) {

         // insert user OK -> now get usr_id

         $sql = "select usr_id from users where usr_password='".$password."' AND usr_email='".$useremail."'";
         $result = mysql_query($sql);
         $row = mysql_fetch_array($result, MYSQL_ASSOC);
         $userid=$row["usr_id"];
         //echo "new userid: ".$userid."<br>";

         // now insert todos_display

         $sql = "insert into todos_display(tdd_usr_id, tdd_tds_id, tdd_updatedate) values(".$userid.", 'y', curdate())";
         //echo "todos_display sql: ".$sql."<br>";
         $result = mysql_query($sql);


         if ($result) {
            $_SESSION['login'] = $useremail;
            $_SESSION['userid'] = $userid;
            $_SESSION['lastname'] = "";
            $_SESSION['firstname'] = "";

            echo "<H3>Signup was successful!</H3>";
            echo "<P>To continue please click on <a href=\"main.php\" target=\"_blank\">Start</a>";
         } else {
            echo "<P>".mysql_error();
         }
      } else {
         echo "<P>".mysql_error();
      }

   }


?>
Return current item: MyTodos