Jump to content

Caesar

Members
  • Posts

    1,025
  • Joined

  • Last visited

    Never

Posts posted by Caesar

  1. You really don't want to do it in 100 different PHP pages. Instead, use methods (See OOP) or functions...all within a single PHP page. That being said, it's possible to display anything you want on a conditional basis. What you're asking is basically the basics of if/else 101.

     

    Something like....

     

    <?php
    
    function loadpage($var) {
    // Your code here
    }
    
        if($_SESSION['loggedin']) loadpage('members');
          else loadpage('login');
    
    ?>

     

    There's of course different approaches, techniques...etc. But yes, more than possible.

  2. You can always do something like...

    <?php
    
    $img_name = md5(time()).$extension;
    
    ?>

     

    Not very likely you'll have duplicates unless, the time/date on the server is changed.

     

    Edit: I assume you're going to store/log the fact they uploaded an image in your db. So yeah, you store the image name and in the same table, the user id associated with it.

  3. Well, your question wasn't very specific. What exactly are you checking? User input? A record stored in a database? A string?

     

     

    Anyway...assuming it's a string or something manually entered in a form (Bad idea to let people enter dates without forcing the format yourself)....

     

    <?php
    
    if(!preg_match('/[0-3][0-9]\/[0-1][0-9]\/2[0][0-9][0-9]/', $date) Errors('date'); //Assuming you wrote an Errors() function.
      else echo 'Email is formatted correctly';
    
    ?>

  4. Look into Object Oriented Programming (OOP). You may not use it for smaller tasks/scripts but when doing commercial/paid work, it makes more sense. It also encourages clean/organized code and will keep you from using repetitive code.

  5. Even a better idea...CSS:

     

    #techcone
    {
        font-size: 11px;
        color: #FF9900;
        font-family: book antiqua;
    }

     

    <html>
    <head>
      	
        <title>More Cowbell</title>
      
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <meta name="robot" content="index, follow" />
        
        <link rel="stylesheet" type="text/css" href="style.css" /> 
        
    </head>
    
    <body>
    
      <div id="techcone">
        The font size, color and font family have been defined in your CSS!!
      </div>
    
    </body>
    </html>

     

    Now....if you are trying to make it dymaic (Your example code isn't clear, as you're using a non HTML tag), you'd use a different method. But you can even use a dynamic style sheet for that as well.

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