Page 2 of 2

Re: Delete emails php... expert assistance greatly appreciated

Posted: Sun Sep 06, 2009 9:36 pm
by Robert07
Can you please post the complete php file all at once (as well as the complete source of any included files) so I can get a bigger picture of what's happening? Do you have root access to the server or is it a shared environment?

Re: Delete emails php... expert assistance greatly appreciated

Posted: Sun Sep 06, 2009 9:57 pm
by scarface222
This is messages.php and I am testing on a local server on my laptop. I have to do a lot more work before I can upload the website to an actual shared server. The include of session.php shouldn't really be relevant it just handles all the session variables but I will paste that underneath. Also I don't know if it is worth mentioning but on this page messages.php, the jquery window used for each message is not functional yet in case you try to test it and wonder what the problem is. I am working on figuring out how to match them with the message id variables.

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 
<head>
<?php
 
include("login/include/session.php");
?>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    
    
    
    <link type="text/css" href="jquery/css/custom-theme/jquery-ui-1.7.2.custom.css" rel="stylesheet" /> 
<script type="text/javascript" src="jquery/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="jquery/js/jquery-ui-1.7.1.custom.min.js"></script>
 
    <link rel="stylesheet" type="text/css" href="css/style.css" />
<!--open messsage window-->
<script type="text/javascript">
    $.ui.dialog.defaults.bgiframe = true;
    $(function() {
        $("#message").dialog({hide: 'clip', modal: true
,width: 600,height: 350,position: 'center',
                            show: 'clip',stack: true,title: 'Login', minHeight: 25,
                            minWidth: 100, autoOpen: false});
                            
                            $('#openbox').click(function() {
            $('#message').dialog('open');
        })
        .hover(
            function(){ 
                $(this).addClass("ui-state-hover"); 
            },
            function(){ 
                $(this).removeClass("ui-state-hover"); 
            }
        ).mousedown(function(){
            $(this).addClass("ui-state-active"); 
        })
        .mouseup(function(){
                $(this).removeClass("ui-state-active");
        });
 
    });
 
       
    </script>
</head>
 
<body>
 
 
    <div id="page-wrap">
 
        <div id="top-bar">
        <a href="index.php"><img src="images/header.png" class="floatleft"></a>
 
 
 
            <div id="right-side">
                
 
                
            </div>
        </div>
        
        <div id="zone-bar">
            <ul>
                <li>
                    <a href="t.php"><span>
                        T &nbsp;
                        
                    </span></a>
                    
                </li>
                <li>
                    <a href="w.php"><span>
                        W &nbsp;
                        
                    </span></a>
                    
                </li>
                <li>
                    <a href="s.php"><span>
                        S &nbsp;
                        
                    </span></a>
                    
                </li>
                <li>
                    <a href="g.php"><span>
                        G &nbsp;
                        
                    </span></a>
                    
                </li>
                <li>
                    <a href="l.php"><span>
                        L &nbsp;
                        
                    </span></a>
                    
                </li>
                <li>
                    <a href="e.php"><span>
                        E &nbsp;
                        
                    </span></a>
                    
                </li>
                <li>
                    <a href="s.php"><span>
                        S &nbsp;
                        
                    </span></a>
                    
                </li>
                <li>
                    <a href="r.php"><span>
                        R &nbsp;
                        
                    </span></a>
                    
                </li>
            </ul>
            
          <form id="main-search" action="search.php" method="get">
                          <label for="search-field" id="search-field-label">Search</label>
                            <input type="text" name="q" tabindex="1" maxlength="255" id="search-field"/>
                          <input type="image" alt="Search" value="Search" src="images/magnifier.png" id="search-button"/>  
              </form>
            
        </div>
        
        <div id="main-content">
            <div id="feature-content">
                
                <div id="feature-left">
                    <h1>Messages</h1>
                    <p>
  <table border="0" cellpadding="10" cellspacing="10">
  <tr><td>from</td> <td>subject</td> <td>date</td></tr>
  <?php
 
if(!$session->logged_in){
 
   header("Location: index.php");
       
}
else if($session->logged_in){
    
    echo '<form action="messages.php" method=\"POST\" ><input type="submit" value="Delete">';
$username=$session->username;
$messages="SELECT * FROM messages WHERE username='$username'";
$query=mysql_query($messages);
while ($row = mysql_fetch_assoc($query)) {
    $from=$row['from'];
 $subject=$row['subject'];
 $date=$row['date'];
 $message=$row['message'];
 $delId=$row['id'];
 echo "<tr><td><input name=\"msg".$delId."\" type=\"checkbox\"></td><td>$from</td> <td><a id=\"openbox\">$subject</a></td> <td>$date</td></tr>";
 echo "<div id=\"message\">$message</div>";
 echo'</form>';
 
 $delCnt=0;
 foreach ($_REQUEST as $key=>$value) {
    if (substr($key,0,3)==="msg") {
      $delId = substr($key,3);
      $qryusersdelete="Delete FROM messages WHERE id='$delId'";
      $rslusersdelete=mysql_query($qryusersdelete);
      $delCnt++;
    }
 }
 if ($delCnt>0) {
     header("Location: messages.php");
 }
 
                
                 
}
}
?>                     
</table>
      
<div id="loginform">
 
</div>
                
                    </p>
                </div>
                
                <div id="feature-right">
                    <div class="feature-mini">
                        <h1>Friends</h1>
                        <p>
 
 <p>
 
 
                        
                        </p>
                    </div>
                    
                    <div class="clear"></div>
                </div>
                <div class="clear"></div>
            </div>
        </div>
        
        <div id="footer">
            
            <a href="about.php">About</a>&nbsp;&nbsp;&nbsp;
            <a href="terms.php">Terms</a>&nbsp;&nbsp;&nbsp;
            <a href="privacy.php">Privacy</a>&nbsp;&nbsp;&nbsp;
            <a href="help.php">Help</a>&nbsp;&nbsp;&nbsp;
        </div>
        
    </div>
    
</body>
 
</html>

Re: Delete emails php... expert assistance greatly appreciated

Posted: Sun Sep 06, 2009 10:06 pm
by scarface222

Code: Select all

<?php
/**
 * Session.php
 * 
 * The Session class is meant to simplify the task of keeping
 * track of logged in users and also guests.
 */
include("database.php");
include("mailer.php");
include("form.php");
 
class Session
{
   var $username;     //Username given on sign-up
   var $userid;       //Random value generated on current login
   var $userlevel;    //The level to which the user pertains
   var $time;         //Time user was last active (page loaded)
   var $logged_in;    //True if user is logged in, false otherwise
   var $userinfo = array();  //The array holding all user info
   var $url;          //The page url current being viewed
   var $referrer;     //Last recorded site page viewed
   /**
    * Note: referrer should really only be considered the actual
    * page referrer in process.php, any other time it may be
    * inaccurate.
    */
 
   /* Class constructor */
   function Session(){
      $this->time = time();
      $this->startSession();
   }
 
   /**
    * startSession - Performs all the actions necessary to 
    * initialize this session object. Tries to determine if the
    * the user has logged in already, and sets the variables 
    * accordingly. Also takes advantage of this page load to
    * update the active visitors tables.
    */
   function startSession(){
      global $database;  //The database connection
      session_start();   //Tell PHP to start the session
 
      /* Determine if user is logged in */
      $this->logged_in = $this->checkLogin();
 
      /**
       * Set guest value to users not logged in, and update
       * active guests table accordingly.
       */
      if(!$this->logged_in){
         $this->username = $_SESSION['username'] = GUEST_NAME;
         $this->userlevel = GUEST_LEVEL;
         $database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time);
      }
      /* Update users last active timestamp */
      else{
         $database->addActiveUser($this->username, $this->time, $_SERVER['REMOTE_ADDR']);
      }
      
      /* Remove inactive visitors from database */
      $database->removeInactiveUsers();
      $database->removeInactiveGuests();
      
      /* Set referrer page */
      if(isset($_SESSION['url'])){
         $this->referrer = $_SESSION['url'];
      }else{
         $this->referrer = "/";
      }
 
      /* Set current url */
      $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF'];
   }
 
   /**
    * checkLogin - Checks if the user has already previously
    * logged in, and a session with the user has already been
    * established. Also checks to see if user has been remembered.
    * If so, the database is queried to make sure of the user's 
    * authenticity. Returns true if the user has logged in.
    */
   function checkLogin(){
      global $database;  //The database connection
      /* Check if user has been remembered */
      if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookid'])){
         $this->username = $_SESSION['username'] = $_COOKIE['cookname'];
         $this->userid   = $_SESSION['userid']   = $_COOKIE['cookid'];
      }
 
      /* Username and userid have been set and not guest */
      if(isset($_SESSION['username']) && isset($_SESSION['userid']) &&
         $_SESSION['username'] != GUEST_NAME){
         /* Confirm that username and userid are valid */
         if($database->confirmUserID($_SESSION['username'], $_SESSION['userid']) != 0){
            /* Variables are incorrect, user not logged in */
            unset($_SESSION['username']);
            unset($_SESSION['userid']);
            return false;
         }
 
         /* User is logged in, set class variables */
         $this->userinfo  = $database->getUserInfo($_SESSION['username']);
         $this->username  = $this->userinfo['username'];
         $this->userid    = $this->userinfo['userid'];
         $this->userlevel = $this->userinfo['userlevel'];
         return true;
      }
      /* User not logged in */
      else{
         return false;
      }
   }
 
   /**
    * login - The user has submitted his username and password
    * through the login form, this function checks the authenticity
    * of that information in the database and creates the session.
    * Effectively logging in the user if all goes well.
    */
   function login($subuser, $subpass, $subremember){
      global $database, $form;  //The database and form object
 
      /* Username error checking */
      $field = "user";  //Use field name for username
      if(!$subuser || strlen($subuser = trim($subuser)) == 0){
         $form->setError($field, "* Username not entered");
      }
      else{
         /* Check if username is not alphanumeric */
         if(!eregi("^([0-9a-z])*$", $subuser)){
            $form->setError($field, "* Username not alphanumeric");
         }
      }
 
      /* Password error checking */
      $field = "pass";  //Use field name for password
      if(!$subpass){
         $form->setError($field, "* Password not entered");
      }
      
      /* Return if form errors exist */
      if($form->num_errors > 0){
         return false;
      }
 
      /* Checks that username is in database and password is correct */
      $subuser = stripslashes($subuser);
      $result = $database->confirmUserPass($subuser, md5($subpass));
 
      /* Check error codes */
      if($result == 1){
         $field = "user";
         $form->setError($field, "* Username not found");
      }
      else if($result == 2){
         $field = "pass";
         $form->setError($field, "* Invalid password");
      }
      
      /* Return if form errors exist */
      if($form->num_errors > 0){
         return false;
      }
 
      /* Username and password correct, register session variables */
      $this->userinfo  = $database->getUserInfo($subuser);
      $this->username  = $_SESSION['username'] = $this->userinfo['username'];
      $this->userid    = $_SESSION['userid']   = $this->generateRandID();
      $this->userlevel = $this->userinfo['userlevel'];
      
      /* Insert userid into database and update active users table */
      $database->updateUserField($this->username, "userid", $this->userid);
      $database->addActiveUser($this->username, $this->time);
      $database->removeActiveGuest($_SERVER['REMOTE_ADDR']);
 
      /**
       * the user has requested that we remember that
       * he's logged in, so we set two cookies. One to hold his username,
       * and one to hold his random value userid. It expires by the time
       * specified in constants.php. Now, next time he comes to our site, we will
       * log him in automatically, but only if he didn't log out before he left.
       */
      if($subremember){
         setcookie("cookname", $this->username, time()+COOKIE_EXPIRE, COOKIE_PATH);
         setcookie("cookid",   $this->userid,   time()+COOKIE_EXPIRE, COOKIE_PATH);
      }
 
      /* Login completed successfully */
      return true;
   }
 
   /**
    * logout - Gets called when the user wants to be logged out of the
    * website. It deletes any cookies that were stored on the users
    * computer as a result of him wanting to be remembered, and also
    * unsets session variables and demotes his user level to guest.
    */
   function logout(){
      global $database;  //The database connection
      /**
       * Delete cookies - the time must be in the past,
       * so just negate what you added when creating the
       * cookie.
       */
      if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookid'])){
         setcookie("cookname", "", time()-COOKIE_EXPIRE, COOKIE_PATH);
         setcookie("cookid",   "", time()-COOKIE_EXPIRE, COOKIE_PATH);
      }
 
      /* Unset PHP session variables */
      unset($_SESSION['username']);
      unset($_SESSION['userid']);
 
      /* Reflect fact that user has logged out */
      $this->logged_in = false;
      
      /**
       * Remove from active users table and add to
       * active guests tables.
       */
      $database->removeActiveUser($this->username);
      $database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time);
      
      /* Set user level to guest */
      $this->username  = GUEST_NAME;
      $this->userlevel = GUEST_LEVEL;
   }
 
   /**
    * register - Gets called when the user has just submitted the
    * registration form. Determines if there were any errors with
    * the entry fields, if so, it records the errors and returns
    * 1. If no errors were found, it registers the new user and
    * returns 0. Returns 2 if registration failed.
    */
   function register($subuser, $subpass, $subemail){
      global $database, $form, $mailer;  //The database, form and mailer object
      
      /* Username error checking */
      $field = "user";  //Use field name for username
      if(!$subuser || strlen($subuser = trim($subuser)) == 0){
         $form->setError($field, "* Username not entered");
      }
      else{
         /* Spruce up username, check length */
         $subuser = stripslashes($subuser);
         if(strlen($subuser) < 5){
            $form->setError($field, "* Username below 5 characters");
         }
         else if(strlen($subuser) > 30){
            $form->setError($field, "* Username above 30 characters");
         }
         /* Check if username is not alphanumeric */
         else if(!eregi("^([0-9a-z])+$", $subuser)){
            $form->setError($field, "* Username not alphanumeric");
         }
         /* Check if username is reserved */
         else if(strcasecmp($subuser, GUEST_NAME) == 0){
            $form->setError($field, "* Username reserved word");
         }
         /* Check if username is already in use */
         else if($database->usernameTaken($subuser)){
            $form->setError($field, "* Username already in use");
         }
         /* Check if username is banned */
         else if($database->usernameBanned($subuser)){
            $form->setError($field, "* User banned");
         }
         else if($database->usernameBanned2($subuser)){
            $form->setError($field, "* User banned");
         }
      }
 
      /* Password error checking */
      $field = "pass";  //Use field name for password
      if(!$subpass){
         $form->setError($field, "* Password not entered");
      }
      else{
         /* Spruce up password and check length*/
         $subpass = stripslashes($subpass);
         if(strlen($subpass) < 4){
            $form->setError($field, "* Password too short");
         }
         /* Check if password is not alphanumeric */
         else if(!eregi("^([0-9a-z])+$", ($subpass = trim($subpass)))){
            $form->setError($field, "* Password not alphanumeric");
         }
         /**
          * Note: I trimmed the password only after I checked the length
          * because if you fill the password field up with spaces
          * it looks like a lot more characters than 4, so it looks
          * kind of stupid to report "password too short".
          */
      }
      
      /* Email error checking */
      $field = "email";  //Use field name for email
      if(!$subemail || strlen($subemail = trim($subemail)) == 0){
         $form->setError($field, "* Email not entered");
      }
      else{
         /* Check if valid email address */
         $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*"
                 ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*"
                 ."\.([a-z]{2,}){1}$";
         if(!eregi($regex,$subemail)){
            $form->setError($field, "* Email invalid");
         }
         $subemail = stripslashes($subemail);
      }
 
      /* Errors exist, have user correct them */
      if($form->num_errors > 0){
         return 1;  //Errors with form
      }
      /* No errors, add the new account to the */
      else{
         if($database->addNewUser($subuser, md5($subpass), $subemail)){
            if(EMAIL_WELCOME){
               $mailer->sendWelcome($subuser,$subemail,$subpass);
            }
            return 0;  //New user added succesfully
         }else{
            return 2;  //Registration attempt failed
         }
      }
   }
   
   /**
    * editAccount - Attempts to edit the user's account information
    * including the password, which it first makes sure is correct
    * if entered, if so and the new password is in the right
    * format, the change is made. All other fields are changed
    * automatically.
    */
   function editAccount($subcurpass, $subnewpass, $subemail){
      global $database, $form;  //The database and form object
      /* New password entered */
      if($subnewpass){
         /* Current Password error checking */
         $field = "curpass";  //Use field name for current password
         if(!$subcurpass){
            $form->setError($field, "* Current Password not entered");
         }
         else{
            /* Check if password too short or is not alphanumeric */
            $subcurpass = stripslashes($subcurpass);
            if(strlen($subcurpass) < 4 ||
               !eregi("^([0-9a-z])+$", ($subcurpass = trim($subcurpass)))){
               $form->setError($field, "* Current Password incorrect");
            }
            /* Password entered is incorrect */
            if($database->confirmUserPass($this->username,md5($subcurpass)) != 0){
               $form->setError($field, "* Current Password incorrect");
            }
         }
         
         /* New Password error checking */
         $field = "newpass";  //Use field name for new password
         /* Spruce up password and check length*/
         $subpass = stripslashes($subnewpass);
         if(strlen($subnewpass) < 4){
            $form->setError($field, "* New Password too short");
         }
         /* Check if password is not alphanumeric */
         else if(!eregi("^([0-9a-z])+$", ($subnewpass = trim($subnewpass)))){
            $form->setError($field, "* New Password not alphanumeric");
         }
      }
      /* Change password attempted */
      else if($subcurpass){
         /* New Password error reporting */
         $field = "newpass";  //Use field name for new password
         $form->setError($field, "* New Password not entered");
      }
      
      /* Email error checking */
      $field = "email";  //Use field name for email
      if($subemail && strlen($subemail = trim($subemail)) > 0){
         /* Check if valid email address */
         $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*"
                 ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*"
                 ."\.([a-z]{2,}){1}$";
         if(!eregi($regex,$subemail)){
            $form->setError($field, "* Email invalid");
         }
         $subemail = stripslashes($subemail);
      }
      
      /* Errors exist, have user correct them */
      if($form->num_errors > 0){
         return false;  //Errors with form
      }
      
      /* Update password since there were no errors */
      if($subcurpass && $subnewpass){
         $database->updateUserField($this->username,"password",md5($subnewpass));
      }
      
      /* Change Email */
      if($subemail){
         $database->updateUserField($this->username,"email",$subemail);
      }
      
      /* Success! */
      return true;
   }
   
   /**
    * isAdmin - Returns true if currently logged in user is
    * an administrator, false otherwise.
    */
   function isAdmin(){
      return ($this->userlevel == ADMIN_LEVEL ||
              $this->username  == ADMIN_NAME);
   }
   
   /**
    * generateRandID - Generates a string made up of randomized
    * letters (lower and upper case) and digits and returns
    * the md5 hash of it to be used as a userid.
    */
   function generateRandID(){
      return md5($this->generateRandStr(16));
   }
   
   /**
    * generateRandStr - Generates a string made up of randomized
    * letters (lower and upper case) and digits, the length
    * is a specified parameter.
    */
   function generateRandStr($length){
      $randstr = "";
      for($i=0; $i<$length; $i++){
         $randnum = mt_rand(0,61);
         if($randnum < 10){
            $randstr .= chr($randnum+48);
         }else if($randnum < 36){
            $randstr .= chr($randnum+55);
         }else{
            $randstr .= chr($randnum+61);
         }
      }
      return $randstr;
   }
};
 
 
/**
 * Initialize session object - This must be initialized before
 * the form object because the form uses session variables,
 * which cannot be accessed unless the session has started.
 */
$session = new Session;
 
/* Initialize form object */
$form = new Form;
 
?>
 

Re: Delete emails php... expert assistance greatly appreciated

Posted: Mon Sep 07, 2009 8:49 am
by Robert07
Ok that helps me understand a bit more what's happening. Can you please paste the contents of form.php and mailer.php as well?

In your main code, you'll want to delete any requested messages before displaying the ones in the db:

Code: Select all

 
$delCnt=0;
 foreach ($_REQUEST as $key=>$value) {
    if (substr($key,0,3)==="msg") {
      $delId = substr($key,3);
      $qryusersdelete="Delete FROM messages WHERE id='$delId'";
      $rslusersdelete=mysql_query($qryusersdelete);
      $delCnt++;
    }
 }
 if ($delCnt>0) {
     header("Location: messages.php");
 }
 
And actually the header command needs to be called before printing anything to the browser - before the first echo or <html> tag, or it should give an error about headers already being sent. So you can put that whole block of code at the top of your file right after including the database file which creates a connection (or from your main file just move the include session.php line above the html tag and put the above block of code next, before the html tag. Once you paste the form.php and mailer.php that may help explain what's happening with the $_GET and $_POST.

Re: Delete emails php... expert assistance greatly appreciated

Posted: Mon Sep 07, 2009 10:27 am
by scarface222
I tried putting that block of code at the top just like you said but the situation remains the same with regards to only the first email deletes regardless of the combination checked along with the first check. Also, when you comment on the header, do you mean the one that goes along with that block of code you made to messages.php?

Code: Select all

<?php 
/**
 * Form.php
 *
 * The Form class is meant to simplify the task of keeping
 * track of errors in user submitted forms and the form
 * field values that were entered correctly.
 *
 */
 
class Form
{
   var $values = array();  //Holds submitted form field values
   var $errors = array();  //Holds submitted form error messages
   var $num_errors;   //The number of errors in submitted form
 
   /* Class constructor */
   function Form(){
      /**
       * Get form value and error arrays, used when there
       * is an error with a user-submitted form.
       */
      if(isset($_SESSION['value_array']) && isset($_SESSION['error_array'])){
         $this->values = $_SESSION['value_array'];
         $this->errors = $_SESSION['error_array'];
         $this->num_errors = count($this->errors);
 
         unset($_SESSION['value_array']);
         unset($_SESSION['error_array']);
      }
      else{
         $this->num_errors = 0;
      }
   }
 
   /**
    * setValue - Records the value typed into the given
    * form field by the user.
    */
   function setValue($field, $value){
      $this->values[$field] = $value;
   }
 
   /**
    * setError - Records new form error given the form
    * field name and the error message attached to it.
    */
   function setError($field, $errmsg){
      $this->errors[$field] = $errmsg;
      $this->num_errors = count($this->errors);
   }
 
   /**
    * value - Returns the value attached to the given
    * field, if none exists, the empty string is returned.
    */
   function value($field){
      if(array_key_exists($field,$this->values)){
         return htmlspecialchars(stripslashes($this->values[$field]));
      }else{
         return "";
      }
   }
 
   /**
    * error - Returns the error message attached to the
    * given field, if none exists, the empty string is returned.
    */
   function error($field){
      if(array_key_exists($field,$this->errors)){
         return "<font size=\"2\" color=\"#ff0000\">".$this->errors[$field]."</font>";
      }else{
         return "";
      }
   }
 
   /* getErrorArray - Returns the array of error messages */
   function getErrorArray(){
      return $this->errors;
   }
};
 
?>
 

Re: Delete emails php... expert assistance greatly appreciated

Posted: Mon Sep 07, 2009 10:29 am
by scarface222

Code: Select all

<?php 
/**
 * Mailer.php
 *
 * The Mailer class is meant to simplify the task of sending
 * emails to users. Note: this email system will not work
 * if your server is not setup to send mail.
 *
 *
 */
 
class Mailer
{
   /**
    * sendWelcome - Sends a welcome message to the newly
    * registered user, also supplying the username and
    * password.
    */
   function sendWelcome($user, $email, $pass){
      $from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
      $subject = "Welcome!";
      $body = $user.",\n\n"
             ."Welcome! You've just registered"
             ."with the following information:\n\n"
             ."Username: ".$user."\n"
             ."Password: ".$pass."\n\n"
             ."If you ever lose or forget your password, a new "
             ."password will be generated for you and sent to this "
             ."email address, if you would like to change your "
             ."email address you can do so by going to the "
             ."My Account page after signing in.\n\n";
 
      return mail($email,$subject,$body,$from);
   }
   
   /**
    * sendNewPass - Sends the newly generated password
    * to the user's email address that was specified at
    * sign-up.
    */
   function sendNewPass($user, $email, $pass){
      $from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
      $subject = "Your new password";
      $body = $user.",\n\n"
             ."We've generated a new password for you at your "
             ."request, you can use this new password with your "
             ."username to log in to the Site.\n\n"
             ."Username: ".$user."\n"
             ."New Password: ".$pass."\n\n"
             ."It is recommended that you change your password "
             ."to something that is easier to remember, which "
             ."can be done by going to the My Account page "
             ."after signing in.\n\n";
             
      return mail($email,$subject,$body,$from);
   }
};
 
/* Initialize mailer object */
$mailer = new Mailer;
 
?>
 

Re: Delete emails php... expert assistance greatly appreciated

Posted: Mon Sep 07, 2009 12:21 pm
by Robert07
When I mentioned the header command, I was referring to this:

Code: Select all

 
header("Location: messages.php");
 
That needs to be executed before any output is printed (including the <html> tag), but of course after the email delete occurs. So the problem is back to the way the parameters are being passed. I just noticed this extra form definition in the main code:

Code: Select all

 
          <form id="main-search" action="search.php" method="get">
 
It doesn't look like that is necessary, because there is no submit button for that form anyway. Try removing that line and the associated </form> tag a few lines below it and see if your values get in the REQUEST array (but not the URL). You also might try putting the delete button after line 63 instead of right after the form definition on line 52.

Re: Delete emails php... solved

Posted: Mon Sep 07, 2009 1:22 pm
by scarface222
You my friend are the most persistent and caring person I have ever met on this forum haha. I have never encountered someone so eager and available to help. I moved the <form> tag and the input submit tag outside the while statement and now the messages function like I want. REALLY appreciate your help man. On another note, I am a fairly new programmer prone to these silly mistakes and I read your profile business website and am interested to know your experience and qualifications in coding and what type of code you are fluent in. I am working on a rather large project that while I am sure I can finish myself, I am afraid their will be small errors or security flaws that I cannot allow and will eventually require someone trustworthy to check through my work of the finished product. If you are interested at all, just leave your contact email and qualifications and I will contact you a couple months likely down the road for a job if I require assistance.

Thanks again,

Geoff

Re: Delete emails php... solved, thanks robert

Posted: Mon Sep 07, 2009 11:00 pm
by Robert07
Hi Geoff,
Thanks for your kind words. I sent you a message but I just remembered you asked about languages. For the last few years I've been focused on php/mysql/javascript/ajax driven websites and perl for offline scripts to manage and manipulate data. I also have several years of experience with java, visual basic, classic ASP, sql server, oracle pl sql, and even sas and matlab, but I haven't worked with those in awhile. My site at http://businesscatalyst.info provides a decent overview of my background and I also have a code section on my blog at http://goodfeelingplace.com. My email is good2behome "at" gmail "dot" com. I've enjoyed helping you, it's like solving crossword puzzles for me. :)
Regards,
Robert

Re: Delete emails php... solved, thanks robert

Posted: Mon Sep 07, 2009 11:29 pm
by scarface222
Sounds good Robert,

I am currently a young entrepreneur and my website is so far entirely php, javascript, mixed with jquery javascript library for some cool effects and mysql for the database. I reviewed your work and you seem like a highly capable and passionate individual when it comes to coding. I will eventually need someone who can really deal with important security issues, optimize performance, and deal with simple flaws I may have missed, and is most of all: highly trustworthy. I will take down your information and we will certainly be in touch when I near a finish on this project a couple months down the road.

Sincerely,

Geoff