hi everybody

this project my graduate project pls help me .. i dont understand where is error and how to sending mail ?

mr.php-------------

<html>
<body>
<table width="380" border="0" cellpadding="3" cellspacing="1" >
<tr>
<td width="33%"><strong>Enter your email : </strong></td>
<td width="67%"><form name="form1" method="post" action="mm.php">
<input name="email_to" type="text" id="mail_to" size="25">
<input type="submit" name="Submit" value="Submit">
</form>
</td>
</tr>
</table>
</body>
</html>

mm---------

<?php

include("config.php");

include("fk.php");

$email = $_POST['email'];
if(!$email)
    {
        echo "enter your mail ";
        include ("mr.php");
        exit();
    }
    $email_kntrl = mysql_query("SELECT * FROM users where email in('".$email."')");
    $email_kntrl2 = mysql_num_rows($email_kntrl);
if($email_kntrl2 == 0)
  {
    echo '<font color="red">havent this mail </font>';
    unset($email);
   include ("mm.php");
   exit();
   }



$new_password = sha1($random_pass);

$sql = mysql_query("update users set sifre='$new_password' where mail='$email'");
$konu = "Yeni Şifreniz:";
$mesaj = "your new password  $random_pass;


mail();//
echo 'we sending ';

?>

config.php------------

<?php
$host = "localhost";
$username = "root";
$password= "";
$db_name="petdb";

// Databasemize baglaniyoruz
@mysql_connect("$host", "$username", "$password");
@mysql_select_db("$db_name")or die("");
 
  if(mysql_errno())
  {
    echo 'Veritabanina baglanilamiyor ...';
    exit;
  }


?>

fk.php-----------



<?php $salt = "abchefghjkmnpqrstuvwxyz0123456789";
  srand((double)microtime()*1000000);
      $i = 0;
      while ($i <= 7) {
            $num = rand() % 33;
            $tmp = substr($salt, $num, 1);
            $random_pass = $random_pass . $tmp;
            $i++;
      }
	  
	  ?>

Recommended Answers

All 8 Replies

Member Avatar for diafol

1. You may consider using the form heading as a <label>, placed before the input field.
2. What's the error, where is it going wrong (line number ??).

If you're on local server, you need to have a smtp or other email server running. This is something you need to set up yourself and is usually a bit of a pain.

not find to mail adress ..
i try to write mail adress... and error :

enter your mail adress (mm.php line 29)

i use to smtp mail server ( xampp mercury ) but i cant send

Member Avatar for diafol

Try changing

<input name="email_to" type="text" id="mail_to" size="25">

To

<input name="email" type="text" id="email" size="25" />

Because you're using

$email = $_POST['email'];

BTW: you're not validating or cleaning form input - this is VERY dangerous. Use a validation pattern - google code used to have a good one. Clean with mysql_real_escape_string().

thank you now working change password ...

but

now give to this error :

Warning: mail() [function.mail]: Failed to connect to mailserver at "smtp.wlink.com.np" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\project\login\mail\mm.php on line 39

Member Avatar for diafol

Yep, that's your local mailserver. Pain ain't it?

What's the code in your mm.php file - it's not too obvious from the original code as you have include(mm.php) in the middle of what I thought was the mm.php file.

Perhaps you've seen this page?

http://www.apachefriends.org/en/xampp-windows.html

i use this xampp mercury for mail server
i working to localhost .. i dont know what am i write to line 57 ?

Member Avatar for diafol

Line 57?? I thought you said the error was coming from line 39.

sorry..
my english is problem

i want to said i m didn't send to mail baceuse i dont know how to use mail function

because i write to line 57... mail(...)

yes i write to line 39 that is ok working know ... but now i dont know how to use mail fuction now this problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.