0

Hello Friends

I written the the code for forgetpassword
in this i have to get the mail when i enter the mailid

the code is as follows

forgetpasswd.php

<form name="f1" method="POST" action="retrieve.php" >
                        <table>
                            <tr><td colspan=3>&nbsp;</td></tr>
                            <tr><td colspan=3>&nbsp;</td></tr>
                            <tr>
                              <td><font color="red">*</font>Enter Email-ID</td>
                              <td>:</td>
                              <td><input type="text" name="email" maxlength=50></td>
                              <td></td>
                              <td><input type="submit" value="GO">
                            </tr>
                            </table>
                 </form>

retrieve.php

<?php

  //getting email value from form forgotPwd.php
  $email = $_POST["email"];


 //connection to database and select database
//include("..\\all\\dbconnection.php");
include("dbconnection.php");
 //include_once("../all/dbconnection.php");

if($_SERVER['REQUEST_METHOD']=='POST' ){
$frq="select * from md_users where EmailId='".$_POST['EmailId']."'";
$fres=mysql_query($frq);
    $frcnt=mysql_num_rows($fres);   
    if($frcnt==1){
        $frow=mysql_fetch_assoc($fres); 
        }


/*//Query to get Login and Password from logindetails table.
$result = mysql_query("select * from clientmaster1 where email='".$email."' and actstatus='1' "); 

//checking execution
if(!$result)
  echo mysql_error();

while($row=mysql_fetch_array($result))
{
   $login =$row[""];
    $loginid=$row["loginid"];
    $pwd=$row["pwd"];
    $name=$row["name"];
    $doc=$row["doc"];
}
*/
            //mail 
            include( "Mail.php");
            $from = "admin@website.com";
            $to = $email;
            $subject = "Forgot Password!";
            $body = "Dear  ".$frow['EmailId']."\nCongratulations!!\nWelcome to roamkerala\nDetails Of Login Registration\nLogin : ".$loginid."\nPassword : ".$frow['Password']."\nYour Profile created on ".$doc;
            //$host = "mail.vkcitycourier.com";
            $host = "mail.website.com";
            $username = "admin@website.com";
            $password = "adminpassword";
            $headers = array ('From' => $from,
            'To' => $to,
            'Subject' => $subject);
            $smtp = Mail::factory('smtp',
            array ('host' => $host,
            'auth' => true,
            'username' => $username,
            'password' => $password));
            $mail = $smtp->send($to, $headers,$body);
            if (PEAR::isError($mail))
            {
                echo("<p>" . $mail->getMessage() . "</p>" ."your password send to you");
            }
            else
            {
                 $err="Login ID and Password has sent successfully to email";

            }

}
?>

The code is working in locally fine
but when i upload this file on server it is not working(the mail is not comming )
can any one please resolve this issue

Thanking u

Edited by Nick Evan: Fixed formatting

5
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by saiprem
0

common issues on transfering files from localhost to the other server is the path... so check for the paths, specially absolute path.. coz your now on a different server.

0

Thanks for reply to all and sir i used the php code tags but the problem is that when i run this code on localhost its working fine but when i uploaded the same file on server its not sending the mail

0

Thanks for reply to all and sir i used the php code tags but the problem is that when i run this code on localhost its working fine but when i uploaded the same file on server its not sending the mail

Even in the localhost also it should not work, because the mail id
in the form is with the name email

<input type="text" name="email" maxlength=50>

and in your code you are calling that as

$_POST

if($_SERVER['REQUEST_METHOD']=='POST' ){
$frq="select * from md_users where EmailId='".$_POST['EmailId']."'";
$fres=mysql_query($frq);
$frcnt=mysql_num_rows($fres);
if($frcnt==1){
$frow=mysql_fetch_assoc($fres);
}

Ok and coming to the error in site, Are you getting any error..
Please give the error if you are getting. If you are not getting any error, try the following code.. I hope it will helps you

$smtpinfo ["host"]        = mail_server_url;
		$smtpinfo ["port"]        = mail_server_port;
		$smtpinfo ["auth"]        = true;
		$smtpinfo ["username"]    = mail_username;
		$smtpinfo ["password"]    = mail_password;
                $mail_object = &Mail::factory ("smtp", $smtpinfo);
		$result = $mail_object->send ($recipients_email_address, $headers_if_any_available, $final_mail_message);

Edited by saiprem: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.