Jump to content
×
×
  • Create New...
  • 0

php recover all id


EnKor

Question

  • Premium

Hi. How can i recover all ID from same email to email?

I have this, but for some reason it dont work.

 

if(isset($_POST['idrecover']) && $_POST['idrecover']=="Recuperar") {
    
    if(checkMail($_POST['idemail'])) {
      
      $email = mysql_real_escape_string($_POST['idemail']);

      
      $getUser = "SELECT login FROM account.account WHERE email='".$email."' LIMIT 100";
      $qryUser = mysql_query($getUser);
      
      if(mysql_num_rows($qryUser)>0) {
      
        $qryPass =  mysql_query($getUser);
        $login = mysql_real_escape_string($getUser);
        
        if($qryPass) {
          echo'<p class="meldung">xxxxxx';
          
          $absender = $serverSettings['titel']." Recuperação";
          $email = $serverSettings['pass_mail'];
          $empfaenger = $_POST['idemail'];
          $mail_body = "
          
          Hellou!! This is realy funny, but dont Work.
          
          
          ID: ".$login." ----------->>>> i wanna see all logins in Here!!!!
          
          
          
         
          
          $titel = "Recuperação de Password ".$serverSettings['titel'];
          
          $header .= "X-Priority: 3\n";
          $header .= "X-Mailer: mtVision Homepage Mailer\n";
          $header .= "MIME-Version: 1.0\n";
          $header .= "From: ".$absender." <".$serverSettings['pass_mail'].">\n";
          $header .= "Reply-To: ".$serverSettings['pass_mail']."\n";
          //$header .= "Content-Transfer-Encoding: 8bit\n"; 
          $header .= "Content-Type: text/plain; charset=iso-8859-1\n";
          
          if(!mail($empfaenger, $titel, $mail_body, $header)) {
            echo'<p class="meldung">xxxxxx';
          }
          
        }
        else {
          echo'<p class="meldung">xxxxxx';
        }
        
      }
      else {
        echo'<p class="meldung">xxxxxx';
      }
      
    }
    else {
      echo'<p class="meldung">xxxxxx';
    }
    
  }

Edited by EnKor
Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0

Try this

 

<?php 
if(isset($_POST['idrecover']) && $_POST['idrecover']=="Recuperar") {
    
    if(checkMail($_POST['idemail'])) {
      
      $email = mysql_real_escape_string($_POST['idemail']);

      
      $query = "SELECT login FROM account.account WHERE email='".$email."' LIMIT 100";
      $result = mysql_query($query);
	  
		echo'<p class="meldung">xxxxxx';
		$absender = $serverSettings['titel']." Recuperação";
		$email = $serverSettings['pass_mail'];
		$empfaenger = $_POST['idemail'];
      if(mysql_num_rows($result)>0) {
      
        //$qryPass =  mysql_query($getUser);
		while($row = mysql_fetch_assoc($result)) {
			$mail_body = "
          
          Hellou!! This is realy funny, but dont Work.
          
          
          ID: ".$row['login']." ----------->>>> i wanna see all logins in Here!!!!";
		}          
          $titel = "Recuperação de Password ".$serverSettings['titel'];
          
          $header .= "X-Priority: 3\n";
          $header .= "X-Mailer: mtVision Homepage Mailer\n";
          $header .= "MIME-Version: 1.0\n";
          $header .= "From: ".$absender." <".$serverSettings['pass_mail'].">\n";
          $header .= "Reply-To: ".$serverSettings['pass_mail']."\n";
          //$header .= "Content-Transfer-Encoding: 8bit\n"; 
          $header .= "Content-Type: text/plain; charset=iso-8859-1\n";
          
          if(!mail($empfaenger, $titel, $mail_body, $header)) {
            echo'<p class="meldung">xxxxxx';
          }
        
      }
      else {
        echo'<p class="meldung">xxxxxx';
      }
      
    }
    else {
      echo'<p class="meldung">xxxxxx';
    }
    
  }

?>

 

Link to comment
Share on other sites

  • 0
  • Premium

It works. But dont make the loop. Cuz only send one ID in that email and i have 23 ( Tests ) xD

 

 

The while loop need to be insine of:

$mail_body = "

 

 

no? :\

Edited by EnKor
Link to comment
Share on other sites

  • 0

i wrote that for you. NOT TESTED!

<?php
if(isset($_POST['idrecover']) && $_POST['idrecover']=="Recuperar") {
    if (checkMail($_POST['idemail'])) {
        $email = mysql_real_escape_string($_POST['idemail']);
        $getUser = "SELECT login FROM account.account WHERE email='" . $email . "'";
        $qryUser = mysql_query($getUser);

        if (mysql_num_rows($qryUser) > 0) {
            // Set empty array
            $foundLogins = array();
            // get all User IDs with the given email
            while ($row = mysql_fetch_array($qryUser)) {
                $foundLogins[] = $row['login'];
            }
            // config email
            $from = "[email protected]"; // email (from)
            $to = "[email protected]"; // email (to)
            $subject = "Subject"; // Subject

            $message = "Found the following IDs with the email " . $email . ":";
            foreach ($foundLogins as $foundLogin) {
                $message .= "ID: " . $foundLogin . " ,";
            }

            // set email header
            $headers = array();
            $headers[] = "MIME-Version: 1.0";
            $headers[] = "Content-type: text/plain; charset=iso-8859-1";
            $headers[] = "From: Sender Name <$from>";
            $headers[] = "Reply-To: Recipient Name <$from>";
            $headers[] = "Subject: {$subject}";
            $headers[] = "X-Mailer: PHP/" . phpversion();

            // send mail
            if (!mail($to, $subject, $message, implode("\r\n", $headers))) {
                echo "Email could not send";
            } else {
                echo "Email send";
            }
        } else {
            echo "No entries found with this email";
        }
    } else {
        echo "email not valid";
    }
} else {
    echo "fill the formular";
}
?>

Edit: Better without foreach:

<?php
if(isset($_POST['idrecover']) && $_POST['idrecover']=="Recuperar") {
    if (checkMail($_POST['idemail'])) {
        $email = mysql_real_escape_string($_POST['idemail']);
        $getUser = "SELECT login FROM account.account WHERE email='" . $email . "'";
        $qryUser = mysql_query($getUser);

        if (mysql_num_rows($qryUser) > 0) {
            // Set empty array
            $foundLogins = array();
            // get all User IDs with the given email
            while ($row = mysql_fetch_array($qryUser)) {
                $foundLogins[] = $row['login'];
            }
            // config email
            $from = "[email protected]"; // email (from)
            $to = "[email protected]"; // email (to)
            $subject = "Subject"; // Subject

            $message = "Found the following IDs with the email " . $email . ": ";
            $comma_separated = implode(",", $foundLogins);
            $finalMessage = $message.$comma_separated;

            // set email header
            $headers = array();
            $headers[] = "MIME-Version: 1.0";
            $headers[] = "Content-type: text/plain; charset=iso-8859-1";
            $headers[] = "From: Sender Name <$from>";
            $headers[] = "Reply-To: Recipient Name <$from>";
            $headers[] = "Subject: {$subject}";
            $headers[] = "X-Mailer: PHP/" . phpversion();

            // send mail
            if (!mail($to, $subject, $finalMessage, implode("\r\n", $headers))) {
                echo "Email could not send";
            } else {
                echo "Email send";
            }
        } else {
            echo "No entries found with this email";
        }
    } else {
        echo "email not valid";
    }
} else {
    echo "fill the formular";
}
?>

 

Edited by Ayaka
  • Love 1
Link to comment
Share on other sites

  • 0
  • Premium

Now it works. Tks Ayaka!

 

Only one more thing. In this way i get in my email all ids like xxxxxx, xxxxxx, xxxxxx,

Is it possible add one <br> ?

If so we will get:

Xxxxxxx,

Xxxxxxx, etc....

Link to comment
Share on other sites

  • 0

Try this

 

<?php
if(isset($_POST['idrecover']) && $_POST['idrecover']=="Recuperar") {
    if (checkMail($_POST['idemail'])) {
        $email = mysql_real_escape_string($_POST['idemail']);
        $getUser = "SELECT login FROM account.account WHERE email='" . $email . "'";
        $qryUser = mysql_query($getUser);

        if (mysql_num_rows($qryUser) > 0) {
            // Set empty array
            $foundLogins = array();
            // get all User IDs with the given email
            while ($row = mysql_fetch_array($qryUser)) {
                $foundLogins[] = $row['login'];
            }
            // config email
            $from = "[email protected]"; // email (from)
            $to = "[email protected]"; // email (to)
            $subject = "Subject"; // Subject

            $message = "Found the following IDs with the email " . $email . ": ";
            $comma_separated = implode(",", $foundLogins);
            $finalMessage = $message.$comma_separated."</br>";

            // set email header
            $headers = array();
            $headers[] = "MIME-Version: 1.0";
            $headers[] = "Content-type: text/plain; charset=iso-8859-1";
            $headers[] = "From: Sender Name <$from>";
            $headers[] = "Reply-To: Recipient Name <$from>";
            $headers[] = "Subject: {$subject}";
            $headers[] = "X-Mailer: PHP/" . phpversion();

            // send mail
            if (!mail($to, $subject, $finalMessage, implode("\r\n", $headers))) {
                echo "Email could not send";
            } else {
                echo "Email send";
            }
        } else {
            echo "No entries found with this email";
        }
    } else {
        echo "email not valid";
    }
} else {
    echo "fill the formular";
}
?>

 

Link to comment
Share on other sites

  • 0

nope. you have to set the linebreak right in and after the implode function. <br> isnt working because you have to set "\r\n" for linebreaks in mail function in this case.

replace

$comma_separated = implode(",", $foundLogins);

with

$comma_separated = implode("\r\n",$foundLogins)."\r\n";

 

Edited by Ayaka
  • Love 1
Link to comment
Share on other sites

  • 0
  • Premium

nope. you have to set the linebreak right after the implode function. <br> isnt working because you have to set "\r\n" for linebreaks in mail function.

replace

$comma_separated = implode(",", $foundLogins);

with

$comma_separated = implode("\r\n",$foundLogins)."\r\n";

 

Now it works 100% ;)

really grateful for your help

  • Love 1
Link to comment
Share on other sites

  • 0
  • Honorable Member

nope. you have to set the linebreak right in and after the implode function. <br> isnt working because you have to set "\r\n" for linebreaks in mail function in this case.

replace

$comma_separated = implode(",", $foundLogins);

with

$comma_separated = implode("\r\n",$foundLogins)."\r\n";

 

that's not 100% right. if you are able to read html emails, <br/> will work - for example in googlemail.

but \r\n is the better solution

Link to comment
Share on other sites

  • 0

nope. you have to set the linebreak right in and after the implode function. <br> isnt working because you have to set "\r\n" for linebreaks in mail function in this case.

replace

$comma_separated = implode(",", $foundLogins);

with

$comma_separated = implode("\r\n",$foundLogins)."\r\n";

 

that's not 100% right. if you are able to read html emails, <br/> will work - for example in googlemail.

but \r\n is the better solution

as i wrote "in this case". We have a text mail not a html mail. Maybe some email clients can read br tags in text mails but it is wrong to do it with this content type

Content-type: text/plain
Edited by Ayaka
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Activity

    1. 14

      CRK - Cronikal [Play now][Official start on April 24, 2022 at 16:00][11 languages available]

    2. 57

      Forever Metin2

    3. 1

      NPC direct item enchant

    4. 37

      Official Mailbox

    5. 0

      [Request] Underground-MT2 Serverfiles, Database , Homepage & Client

    6. 0

      3 countries 3 phrases

    7. 1

      NPC direct item enchant

    8. 0

      Origins2 Global | International | A new concept - 10.06.2022

  • Recently Browsing

    • No registered users viewing this page.

Important Information

Terms of Use / Privacy Policy / Guidelines / 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.