Jump to content

marcus

Members
  • Posts

    1,842
  • Joined

  • Last visited

Posts posted by marcus

  1. Also if you were to have multiple checkboxes [say you were deleting pieces of mail]

     

    <input type="checkbox" name="mail[]" value="1">
    <input type="checkbox" name="mail[]" value="2">
    <input type="checkbox" name="mail[]" value="3">
    <input type="checkbox" name="mail[]" value="4">
    <input type="checkbox" name="mail[]" value="5">
    

     

    Then:

     

    $mail = $_POST[mail];
    
    if($mail){
    echo "You selected:<br>\n";
      foreach($mail AS $mailid){
      echo $mailid . "<br>\n";
      }
    }else {
    echo "No mail selected\n";
    }
    

  2. <input type="checkbox" name="name" value="1">
    

     

    If the box is checked, the value is 1, if it's not checked it will have no value.

     

    If the value is stored in your database, just select it, say if the value in the database equaled one then the box would be checked:

     

    $sql = "SELECT * FROM `tbl_name` WHERE `value`= 'value'";
    $res = mysql_query($sql) or die(mysql_error());
    $row = mysql_fetch_assoc($res);
    
    if($row[name] == 1){
    $check = " CHECKED";
    }else {
    $check = "";
    }
    
    echo "<input type=\"checkbox\" name=\"name\" value=\"1\"$check>\n";
    

     

    Then passing it:

     

    $name = $_POST['name'];
    
    if($name){
      $sql = "SELECT * FROM `tbl_name` WHERE `value` ='value'";
      $res = mysql_query($sql) or die(mysql_error());
      $row = mysql_fetch_assoc($res);
        if($name == $row[name]){
        //no need to update
        }else {
        //update query
        }
    }else {
    //no update
    }
    

  3. You can't call the file without the extension, you could always do something like:

     

    if(file_exists("$_SESSION[id].gif")){
    $pic = "$_SESSION[id].gif";
    }else {
    if(file_exists("$_SESSION[id].jpg")){
    $pic = "$_SESSION[id].jpg";
    }else {
    if(file_exists("$_SESSION[id].bmp")){
    $pic = "$_SESSION[id].bmp";
    }else {
    $pic = "nopic.gif";
    }
    

     

    Try that.

  4. Well the profile itself would just contain basic information about the account, and the user profile that the user has designed themselves.

     

    So basically you want to have some main fields in your database:

     

    -username

    -age

    -email

    [other info they would show on their page]

     

    then their actually profile make a text field named "description"

     

    Say you wanted to have the profile URL look something like: /users/profile:username

     

    MOD Rewrite does the trick there: [put into your .htaccess]

    RewriteEngine On
    RewriteRule ^users/profile\[^*]*)$ /profile.php?username=$1 [L]
    

     

    Then profile.php would consist of something as such:

     

    <?php
    $username = $_GET[username];
    //you can protect it later
    
    $sql = "SELECT * FROM `users` WHERE `username`= '$username'";
    $res = mysql_query($sql) or die(mysql_error());
    
    if(mysql_num_rows($res) == 0){
    echo "<b>This user does not exist!</b>\n";
    }else {
    $row = mysql_fetch_assoc($res);
    
    echo "<table border=0 cellspacing=3 cellpadding=3 width=600>\n";
    echo "<tr><td align=center>Welcome to <b>$username's</b> profile</td></tr>\n";
    echo "<tr><td valign=top>$row[description</td></tr>\n";
    echo "<tr><td valign=top>$username's Stats:<br>Age: $row[age]<br>E-Mail: <a href=\"mailto:$row[email]\">$row[email]</a></td></tr>\n";
    echo "</table>\n";
    }
    
    ?>
    

     

    Now of course you could easily edit it to make it your own.

  5. Since your cookie has a value I suggest checking to see if the cookie has the value you set it to.

     

    So just use ONE if statement to see if the cookie equals that, then if it does, it's there first time, or they edited the cookie.

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