Hi...tried to send email notification in php but not successful. When i check my email there is no email notification received. Below is the coding. Once the user click notify button, an email notification supposed to be sent to responsible person...Please advise...Thanks a lot.

<?php
error_reporting(E_ALL ^ E_NOTICE);
 $_SESSION['Targetid'];
 $_SESSION["Progressid"];
$conn = mysql_connect("mysql","pqa","pq");
mysql_select_db("pqad",$conn);

if(count($_POST)>0) {

mysql_query("UPDATE progress set Quanprogress4='" . $_POST["Quanprogress4"] . "', Qualprogress4='" . $_POST["Qualprogress4"] . "' WHERE Targetid='" . $_SESSION["Targetid"] . "' and Progressid='" . $_SESSION["Progressid"] . "'");
$message = "Record Modified Successfully";
}

$result = mysql_query("SELECT * FROM progress WHERE Progressid='" . $_SESSION["Progressid"] . "'");
$row= mysql_fetch_array($result);
?>
<html>
<head>
<title>Add New User</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<form name="frmUser" method="post" action="">
<div style="width:500px;">
<div class="message"><?php if(isset($message)) { echo $message; } ?></div>
<div align="right" style="padding-bottom:5px;"><a href="list_progress4.php" class="link"><img alt='List' title='List' src='images/list.png' width='15px' height='15px'/> List Progress</a></div>
<p><b>1.Target</b></p>
a.i.Quantitative Progress (e.g. average,numerical,%,sum): <input type="hidden" name="Progressid" class="txtField" value="<?php echo $row['Progressid']; ?>"><input type="text" name="Quanprogress4" class="txtField" value="<?php echo $row['Quanprogress4']; ?>"><br>
a.ii.Qualitative Progress: <input type="text" name="Qualprogress4" class="txtField" value="<?php echo $row['Qualprogress4']; ?>"><br> 
<input type="hidden" name="Targetid" ><br> 
<td colspan="2"><input type="submit" name="submit" value="Submit" class="btnSubmit"></td>
</div>
</form>
</body></html>
<p><b>3.Improvement Plan</b></p>

Team Leader:<input type="text" name="Pic" value="<?php echo $_SESSION["Username"];?>" ><br>


<?php
$con = mysql_connect("mysql","pqa","pq");
if (!$con)


    {


die('Could not connect: ' . mysql_error());


    }


mysql_select_db("pqad", $con);
$sql="select * from improvement_plan";
$myData=mysql_query($sql,$con);
echo "<table border=1>
<tr>

<th>Responsible</th>;
<th>Notify</th>;
</tr>";


    while ($record=mysql_fetch_array($myData)){


echo "<tr>";
echo "<td>" . $record['Responsible4'] . "</td>";
echo"<td>" . $record['Notify4'] . "</td>";
echo "</tr>";


    }


echo "</table>";
mysql_close($con);
?>

<form action="" method="post">


        <input type="submit" value="Notify" />


    <input type="hidden" name="Notify4" value="Notify" />
</form>
<?php



    }


echo 'Message has been sent'; */
?>
<?php
$email=$_POST['email'];
$name=$_POST['name'];
$subject = "New Mailing List Signup";
$sendto = "email@domain.com";
$body = "This is the information filled out for their signup. /n /n Name: $name /n Email: $email /n /n This signup was generated by your server.";
mail($sendto,$subject,$message);
?>
 </div>
</div>
</div>
</form> 
<?php


    //}


?>
</body>
</html> 
<?php include('ipdfooter.php');?>

The code seems fine to me.

Just a quick question - are you testing it on an already live website or are you testing it via your localhost?

Hi...am testing it on localhost...Thanks.

I had this problem when testing on localhost once...

The thing was, is that my xampp server didn't have a functioning mail server (SMTP). Unfortunately, you need to upload your script to a functioning server with SMTP installed/working (if I were you I'd just create a test/ directory on your webserver).

I believe it's possible to get SMTP working on XAMPP using this and theres a ZIP download to try out. I've never used this though so haave no idea how good it is.

In a nutshell: create a test/ directory on your webserver and test your scipt there.

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.