Jump to content

zachatk1

Members
  • Posts

    38
  • Joined

  • Last visited

    Never

Posts posted by zachatk1

  1. I'm not exactly sure why the submit buttons don't work when having the file (main.php) included in the site. It displays everything nicely but when you click the login, register or any form submit button it brings you to a unknown page. It's supposed to refer back to the same page with this referrer variable code thing for when you login or if there is a mistake it says that your username isn't correct or something so it's important to have.

     

    The login system only actually works when you go to the link main.php so I was thinking if I embed like a window into the site it would act the same and actually work.

     

    EDIT: Also when using the include, the page doesn't stretch, it acts like their is nothing there. Is there a way to work around this? I was thinking of just adding a bunch of <br> for a cheap work around to extend the body background.

  2. I think I finally figured out what my problem is! I have this huge login system that I got and I think it's designed so that in order to login it has a popup window come up. Well I want embed this page so the user can login right their on the page. Before I was using include but that screws up all the submit buttons. Anyone know of a simple code to embed a page?

  3. Alright so I created a MySQL database that has 5 tables each named a brand of a dirt bike.

     

    In each table their are 2 fields, one INDEX_ID and MODELS.

     

    Under that for rows I have every model bike named.

     

    A quick question before I get onto what I want to do:

     

    Can data be added underneath the rows?

     

    For example, users will be able to submit information about each bike model. If each bike model is a row, can there be a category past that row or do I need to make each field a model name and just have a ton of fields and have the rows be the information users submit.

     

    To make it easier to understand I'll post the SQL code for the brand Honda:

     

    CREATE TABLE `Honda` (

      `INDEX_ID` int(3) NOT NULL auto_increment,

      `MODELS` varchar(20) collate latin1_general_ci NOT NULL,

      PRIMARY KEY  (`INDEX_ID`)

    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=23 ;

     

    --

    -- Dumping data for table `Honda`

    --

     

    INSERT INTO `Honda` VALUES(1, 'CR85');

    INSERT INTO `Honda` VALUES(2, 'CR125');

    INSERT INTO `Honda` VALUES(3, 'CR250');

    INSERT INTO `Honda` VALUES(4, 'CRF100');

    INSERT INTO `Honda` VALUES(5, 'CRF150');

    INSERT INTO `Honda` VALUES(6, 'CRF230');

    INSERT INTO `Honda` VALUES(7, 'CRF250X');

    INSERT INTO `Honda` VALUES(8, 'CRF250R');

    INSERT INTO `Honda` VALUES(9, 'CRF450X');

    INSERT INTO `Honda` VALUES(10, 'CRF450R');

    INSERT INTO `Honda` VALUES(11, 'CRF50');

    INSERT INTO `Honda` VALUES(12, 'CRF70');

    INSERT INTO `Honda` VALUES(13, 'CRF80');

    INSERT INTO `Honda` VALUES(14, 'XR650');

    INSERT INTO `Honda` VALUES(15, 'CR500');

    INSERT INTO `Honda` VALUES(16, 'XR100');

    INSERT INTO `Honda` VALUES(17, 'XR200');

    INSERT INTO `Honda` VALUES(18, 'XR250');

    INSERT INTO `Honda` VALUES(19, 'XR400');

    INSERT INTO `Honda` VALUES(20, 'XR50');

    INSERT INTO `Honda` VALUES(21, 'XR70');

    INSERT INTO `Honda` VALUES(22, 'XR80');

     

    Anyway I still need to figure out how to have this under a form that a user can use to select the bike they want to submit information about. A code like this perhaps?:

     

    <?
    $connection = mysql_connect("localhost","user","pass");
    $fields = mysql_list_fields("dbname", "table", $connection);
    $columns = mysql_num_fields($fields);
    echo "<form action=page_to_post_to.php method=POST><select name=Field>";
    for ($i = 0; $i < $columns; $i++) {
    echo "<option value=$i>";
    echo mysql_field_name($fields, $i);
    }
    echo "</select></form>";
    ?>
    

     

    Thanks.

  4. Boy that sounds a little difficult. I think I want to get it working first before I do any formatting and display. I need my previous question answered first on how to do the PHPMyAdmin thing.

  5. Ok I'm slightly confused!  :'(

     

    Just to go over it I make a table named the make (such as ktm or yamaha). For this example the table is called KTM.

     

    Then for fields I make: index_id for numbering and set auto_increment.

     

    Then do I add the model name in each field? For example in phpMyAdmin it would look like this:

     

    Fields:      Type:    Coallation.... All these different things and settings.

     

    index_id... int (3).... auto_increment... primary

    50sx

    65sx

    85sx

    125sx

    150sx

    250sx-f

    350sx-f

    450sx-f

    125exc

    200exc...

     

    and so on.

     

    OR

     

    Do I do create a table called KTM for example

     

    Create a field index_ip (same thing as above)

     

    Create a field called models

     

    Inside models create rows that are all the model names.

     

    Thanks

     

     

  6. The login system I figured I'd start out by modifying someone elses (jpmaster77). I have learned the basics just by doing that and how the code works. The login system is almost up and running except my one issue which I will figure out soon.

     

    I made a nice list of the forms to get an idea of what I'm looking at. The only problem I see is the models. There are going to be so many that I don't know if I can keep track! Any way to make this easier? :confused:

     

    //BIKE MODELS

     

    //Drop Down List:

     

    Makes:

     

    KTM

    Suzuki

    Kawasaki

    Yamaha

    Honda

     

    //When selected, the year box comes up. User needs to be able to select as many years he wants (perhaps check boxes):

     

    Years:

     

    2000

    2001

    2002

    2003

    2004

    2005

    2006

    2007

    2008

    2009

    2010

    2011

    Any

     

    //Every Model of Bike based on the year and the make selected above. Amount can range from 0-20!

     

    Model:

     

    //Varies for each make and year.

     

     

     

    //When selected, drop down menu of a few options ( {} groups together). ()= Examples )

     

    {

    Type:

     

    Performance

    Repair

     

    Stage:

     

    Stage 1 (stock)

    Stage 2 (minor expenses but no engine work)

    Stage 3 (expensive and usually require motor to be taken apart)

     

    Difficulty:

     

    Easy (Cutting a Wire, Taking off a Butt Plate)

    Medium (Jetting, Drilling Exhuast)

    Hard (Changing Ignition Map, Replacing Piston)

    }

     

    //Now this is where the user types in information about the mod.

     

    Title of Mod:

     

    Directions: (Be as descriptive as possible)

     

    //Big Form

     

     

    Additional Information/Links: (optional)

     

     

  7. Hey

     

    First let me say I am not asking exactly how to do this. Just the best method of what I want to do. The idea is to have a database of every model of a dirt bike. A user who is logged in to the system can submit data for a dirt bike (I can create forms for this). On the main page of the database I need to be able to have the user select what model bike and year or years to find the information people submitted in a nice list. Do  you think this is to big of a project? I'm doing this as a hobby type thing so there really is no time schedule.

     

    For making the database:

     

    Would an array be best? Are there any examples somewhat close to what I'm talking about?

  8. Update:

     

    I found this piece of code:

     

    /* Set referrer page */
          if(isset($_SESSION['url'])){
             $this->referrer = $_SESSION['url'];
          }else{
             $this->referrer = "/";
          }
    
          /* Set current url */
          $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF'];
       }

     

    I think it's supposed to set the current page as the referrer. I'm not to good at PHP yet so can anyone check it over or see what's going on?

     

    Thanks!

  9. Maybe I should I explain where the code came from. It is jpmaster77's login script. I don't understand how it could work.. that's why I was wondering if someone knew. The referring thing is supposed to bring you back to the original page I believe. I could hard code it but it wouldn't work for times when the user has to go back and fill in the correct password if they filled it in wrong for example.

  10. Hey!

     

    I am having issues with my site not going to the correct page after submitting a form to login or register or anything in that regards. The script that referrers the user is poster below:

     

    <?
    /**
    * Process.php
    * 
    * The Process class is meant to simplify the task of processing
    * user submitted forms, redirecting the user to the correct
    * pages if errors are found, or if form is successful, either
    * way. Also handles the logout procedure.
    *
    * Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
    * Last Updated: August 19, 2004
    */
    include("session.php");
    
    class Process
    {
       /* Class constructor */
       function Process(){
          global $session;
          /* User submitted login form */
          if(isset($_POST['sublogin'])){
             $this->procLogin();
          }
          /* User submitted registration form */
          else if(isset($_POST['subjoin'])){
             $this->procRegister();
          }
          /* User submitted forgot password form */
          else if(isset($_POST['subforgot'])){
             $this->procForgotPass();
          }
          /* User submitted edit account form */
          else if(isset($_POST['subedit'])){
             $this->procEditAccount();
          }
          /**
           * The only other reason user should be directed here
           * is if he wants to logout, which means user is
           * logged in currently.
           */
          else if($session->logged_in){
             $this->procLogout();
          }
          /**
           * Should not get here, which means user is viewing this page
           * by mistake and therefore is redirected.
           */
           else{
              header("Location: index.php");
           }
       }
    
       /**
        * procLogin - Processes the user submitted login form, if errors
        * are found, the user is redirected to correct the information,
        * if not, the user is effectively logged in to the system.
        */
       function procLogin(){
          global $session, $form;
          /* Login attempt */
          $retval = $session->login($_POST['user'], $_POST['pass'], isset($_POST['remember']));
          
          /* Login successful */
          if($retval){
             header("Location: ".$session->referrer);
          }
          /* Login failed */
          else{
             $_SESSION['value_array'] = $_POST;
             $_SESSION['error_array'] = $form->getErrorArray();
             header("Location: ".$session->referrer);
          }
       }
       
       /**
        * procLogout - Simply attempts to log the user out of the system
        * given that there is no logout form to process.
        */
       function procLogout(){
          global $session;
          $retval = $session->logout();
          header("Location: logout.php");
       }
       
       /**
        * procRegister - Processes the user submitted registration form,
        * if errors are found, the user is redirected to correct the
        * information, if not, the user is effectively registered with
        * the system and an email is (optionally) sent to the newly
        * created user.
        */
       function procRegister(){
          global $session, $form;
          /* Convert username to all lowercase (by option) */
          if(ALL_LOWERCASE){
             $_POST['user'] = strtolower($_POST['user']);
          }
          /* Registration attempt */
          $retval = $session->register($_POST['user'], $_POST['pass'], $_POST['email']);
          
          /* Registration Successful */
          if($retval == 0){
             $_SESSION['reguname'] = $_POST['user'];
             $_SESSION['regsuccess'] = true;
             header("Location: ".$session->referrer);
          }
          /* Error found with form */
          else if($retval == 1){
             $_SESSION['value_array'] = $_POST;
             $_SESSION['error_array'] = $form->getErrorArray();
             header("Location: ".$session->referrer);
          }
          /* Registration attempt failed */
          else if($retval == 2){
             $_SESSION['reguname'] = $_POST['user'];
             $_SESSION['regsuccess'] = false;
             header("Location: ".$session->referrer);
          }
       }
       
       /**
        * procForgotPass - Validates the given username then if
        * everything is fine, a new password is generated and
        * emailed to the address the user gave on sign up.
        */
       function procForgotPass(){
          global $database, $session, $mailer, $form;
          /* Username error checking */
          $subuser = $_POST['user'];
          $field = "user";  //Use field name for username
          if(!$subuser || strlen($subuser = trim($subuser)) == 0){
             $form->setError($field, "* Username not entered<br>");
          }
          else{
             /* Make sure username is in database */
             $subuser = stripslashes($subuser);
             if(strlen($subuser) < 5 || strlen($subuser) > 30 ||
                !eregi("^([0-9a-z])+$", $subuser) ||
                (!$database->usernameTaken($subuser))){
                $form->setError($field, "* Username does not exist<br>");
             }
          }
          
          /* Errors exist, have user correct them */
          if($form->num_errors > 0){
             $_SESSION['value_array'] = $_POST;
             $_SESSION['error_array'] = $form->getErrorArray();
          }
          /* Generate new password and email it to user */
          else{
             /* Generate new password */
             $newpass = $session->generateRandStr(;
             
             /* Get email of user */
             $usrinf = $database->getUserInfo($subuser);
             $email  = $usrinf['email'];
             
             /* Attempt to send the email with new password */
             if($mailer->sendNewPass($subuser,$email,$newpass)){
                /* Email sent, update database */
                $database->updateUserField($subuser, "password", md5($newpass));
                $_SESSION['forgotpass'] = true;
             }
             /* Email failure, do not change password */
             else{
                $_SESSION['forgotpass'] = false;
             }
          }
          
          header("Location: ".$session->referrer);
       }
       
       /**
        * procEditAccount - Attempts to edit the user's account
        * information, including the password, which must be verified
        * before a change is made.
        */
       function procEditAccount(){
          global $session, $form;
          /* Account edit attempt */
          $retval = $session->editAccount($_POST['curpass'], $_POST['newpass'], $_POST['email']);
    
          /* Account edit successful */
          if($retval){
             $_SESSION['useredit'] = true;
             header("Location: ".$session->referrer);
          }
          /* Error found with form */
          else{
             $_SESSION['value_array'] = $_POST;
             $_SESSION['error_array'] = $form->getErrorArray();
             header("Location: ".$session->referrer);
          }
       }
    };
    
    /* Initialize process */
    $process = new Process;
    
    ?>
    

     

    All it does is bring you to a unknown page.

     

    Thanks!

×
×
  • 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.