Jump to content

Wolphie

Members
  • Posts

    682
  • Joined

  • Last visited

    Never

Posts posted by Wolphie

  1. A) Why not separate the name into separate columns, and

    B) You can always use mysql string functions in the query to extract the last name, but this or any use of php code to accomplish this will always be slower than using option A).

     

    You've just got to remember, the over-all system will thereby be improved by doing so.

  2. That's because it should be

    if (!isset($_SESSION['id'])) { ... }

    You want to check if the user hasn't logged in (i.e. the ID session variable hasn't been set) then re-direct to index.php otherwise display the page.

     

    You've got it the opposite at the moment.

  3. The code:

    <?php
    if(isset($S_SESSION["id"])) {
    session_start();
    connectdb();
    $username = $_SESSION["username"];
    $query = mysql_query("SELECT * FROM ov_users WHERE email = '".$username."'");
    $rows = mysql_num_rows($query);
    if($rows = 0 || session_id() != $_session["id"]) {
    session_destroy();
    header("location:index.php");
    }
    				}
    

     

    The first line

    $S_SESSION["id"]

     

    should be

     

    $_SESSION["id"]

     

    Simple typo...

  4. i know a small code it is not of ur requirement but i think this would give u an idea

     

    
    <? 
    
    //set the urls 
    $urls = array("http://google.com" ,"http://hotmail.com" ,"http://phpfreecode.com" ); 
    
    //set the text links 
    $text = array("Google" ,"Hotmail" ,"phpfreecode"); 
            srand(time()); 
    
    //set the number in (rand()%3); for however many links there are 
            $random = (rand()%3); 
    echo ("<a href = \"$urls[$random]\">$text[$random]</a>")."<br>"; 
    
    
    ?>

     

    I don't see how that will echo all of the links?

     

    Straight from PHP.net for associative arrays, keeping the key => value pairs in tact.

     

    <?php
    function shuffle_assoc($array) {
      $keys = array_keys($array);
      
      // Shuffle the keys
      shuffle($keys);
      
      // Re-assign each new ordered key and value pair to a new array
      foreach($keys as $key) {
        $new[$key] = $array[$key];
      }
      
      // Return the new array
      return $new;
    }
    
    // Array of websites, the URL is the key and the label is the value
    $sites = array('http://www.google.com/' => 'Google', 'http://www.phpfreaks.com/' => 'PHP Freaks');
    
    // Loop through each element in the newly ordered array
    foreach (shuffle_assoc($sites) as $key => $val) {
      echo '<a href="'. $key .'">'. $val .'</a><br />';
    }
    ?>
    

     

    If you're getting these values from a database then it's best you use the RAND() MySQL function.

  5. The quickest and easiest way I can see is

    <?php
    $array['a'][0] = 3;
    $array['a'][1] = 1;
    $array['b'][0] = 2;
    $array['b'][1] = 1;
    $array['c'][0] = 0;
    $array['c'][1] = 1;
    
    foreach (array_keys($array) as $key) {
      $array[$key] = array_sum($array[$key]);
    }
    
    print_r($array);
    ?>

    Array ( 
      [a] => 4 
      [b] => 3 
      [c] => 1 
    )
    

  6. I agree, keeping PHPFreaks the way that it is has proved successful thus far. Don't try and fix something that doesn't need fixing, that's where Facebook is beginning to go wrong.

     

    Although, I've been playing about with "MyBB". Which is another open-source and free forum solution, it's pretty nice.

  7. Don't use float.

     

    <div id="display_message_item">
    <div id="list_right">
    <img src="images/thumb_down.jpg" />
    <img src="images/thumb_up.jpg" />
    </div>
    <div id="list_left">
    <p>by :: 767</p>
    <p> Enter your text here. Enter your text here. Enter your text here. </p>
    </div>
    

     

    #display_message_item{
    border: solid 1px #666666;
    min-height: 90px;
    margin: 10px 0 10px 0;
    padding-bottom: 5px;
    }
    
    #list_left{
    width: 390px;
    }
    
    #list_right{
    width: 80px;
    float:right;
    }
    

  8. Try this:

    <?php
    
    /* Incoming Subject and Email Variables - Fixed */
    
       $emailSubject = 'Message from example';
       $webMaster = 'example@hotmail.com';
    
    /* Gathering Data Variables - User Data */
    
       $email = $_POST['email'];
       $name = $_POST['name'];
       $telephone = $_POST['telephone'];
       $message = $_POST['message'];
       
       $body = <<<EOD
    <br><hr><br>
    Email: $email <br>
    Name: $name <br>
    Telephone: $telephone <br>
    Comments: $message <br>
    EOD;
    
       $headers = "From: $email\r\n";
       $headers .= "Content-type: text/html\r\n";
       $success = mail($webMaster, $emailSubject, $body, $headers);
       
    /* Results rendered as code */
    
       $theResults = <<<EOD
    <html> 
    <head> 
    <title>JakesWorks - travel made easy-Homepage</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
    <style type="text/css"> 
    <!--
    body {
       background-color: #f1f1f1;
       font-family: Verdana, Arial, Helvetica, sans-serif;
       font-size: 12px;
       font-style: normal;
       line-height: normal;
       font-weight: normal;
       color: #666666;
       text-decoration: none;
    }
    --> 
    </style> 
    </head> 
    <body> 
    <div> 
      <div align="left">Thank you for your interest! Your email will be answered very soon!</div> 
    </div> 
    </body> 
    </html>
    EOD;
    echo $theResults;  
    ?>

     

  9. All cookies are domain specific. There is no such thing as an "open" cookie that is sent by the browser to all domains.

     

    So then how does Facebook store cookies that enables other websites to identify your Facebook identity?

  10. Other websites could quite possibly access your cookies (which is bad if they contain user sensitive information).

     

    Facebook, for example have a few 'open' cookies where they're accessed by many websites you may visit.

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