Jump to content

Caesar

Members
  • Posts

    1,025
  • Joined

  • Last visited

    Never

Posts posted by Caesar

  1. <?php
    
       if((!isset($_SESSION['username'])) | (!isset($_SESSION['userid']))) {
      
         echo'
         <form action="" method="post">
    
         <table align="left" border="0" cellspacing="0" cellpadding="3">
           <tr><td>Username:</td></tr><tr><td><input type="text" name="username" size="15" maxlength="30" /></td></tr>
           <tr><td>Password:</td></tr><tr><td><input type="password" name="password" size="15" maxlength="30" /></td></tr>
           <tr><td><input type="submit" name="sublogin" value="Login" /></td></tr>
         </table>
    
         </form>';
       }
    
    ?>

     

     

  2. Well it was for both really, to find out how to do it and how it works, and to have the ability to create my own if I ever need to, or if I'm having a problem with one I could have more of an insight to what the problem might be

     

    Understandable...and I would (And have) code one for learning purposes...but definitely not to provide to a client. Why? Well, because with shop's already available that provide ready made modules and plugins for tons of different payment gateways, shipping modules, etc. And then providing updates with new themes and new plugins for newer features/payment gateways....I wouldn't want to keep troubleshooting or providing support. Let someone else do it. Why reinvent the wheel...unless I was coding the software to sell it as an ecommerce solution to the masses.

  3. You mean...?

     

    <?php
    
    $object->method($variable);
    
    ?>

     

    <?php
    
    $array = array('poop'=>'caca', 'pee'=>'urine');
    
    ?>

     

    Look into OOP/Objects and arrays. But yeah, don't get ahead of yourself, start with the very basics. Will learn much much better.

  4. There are plenty of robust shopping carts out there already. Is this for learning purposes or you actually want to go commercial with it? If you're making one for a client, alls I can say is, you're better off using an existing solution, so that you don't have to provide constant support/updates.

  5. Store the date as a timestamp and then format it any way you want when you want to display it.

     

    <?php
    
    //Current timestamp - Ready to be inserted into your db.
    $mydate = time(); 
    //Takes timestamp and formats it to display as: June 26, 2007
    $showdate = date("M d, Y", $mydate);
    
    ?>

  6. Scrap this....

     

        $titl=$dat['title'];

          $crea=$dat['creator'];

          $subj=$dat['subject'];

          $foru=$dat['forum'];

          $tit=str_replace(" ", "-", $titl);

          $cre=str_replace(" ", "-", $crea);

          $sub=str_replace(" ", "-", $subj);

          $for=str_replace(" ", "-", $foru);

     

    And try this...

     

    <?php
    
       function do_it($dat) {
    
          foreach($dat as $newdat) {
            $newdat = str_replace(" ", "-", $newdat);
          }
        return $newdat;
      }
    ?>

     

  7. That's not your business, when I tell you what the values contain. And yes, I know they contain that, because they all print out normally! However, with spaces and not "-" which it should be doing! The array is being assigned from a SQL database.

     

    I don't think you're getting it.

     

    If the flow/logic in your code is just like that snippet you showed, then think about it....you're doing the string replace after the array values have been defined....and printing out any of the $dat isn't going to go through the string replacing. Of course, that is going only by the small snippet of code you showed.

  8. Of course, you should be checking against your db (or wtvr) to make sure the login validates. And you also want to scrub/clean the input to make sure your script is not vulnerable to XSS/SQL injection.

  9. Let's break this down in a lot more simple steps, for the sake of understanding what's going on.

     

    <?php
    
      //Define the variables $username & $password
    
      $username = $_POST['username']; //Assuming you're posting from a form where
      $password = $_POST['password']; //the fields are 'username' & 'password'
    
        if(isset($_POST['username']) && isset($_POST['password'])) {
    
          session_start();
    
          //If the form has been submitted, then initialize the session and define the session variables
          $_SESSION['username'] = $username;
          $_SESSION['password'] = $password;
    
          echo 'Welcome '.$username.' (<a href="logout.php">Logout</a>)';
        }
    
          else {
            echo' Welcome Guest!<br /> <a href="login.php">Login</a> | <a href="register.php">Register</a>';
          }
    
    ?>

     

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