Click here to Skip to main content
15,905,587 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<pre lang="PHP">
HTML
<body>
<form name="FromID" method="post"><br>
<br>
<div align="center" style="font-family:Times New Roman; font-size:25px;font-weight:bold; ">COMPLAINTS ASSIGNED</div>
<br>
<br>
<table border="1%"  cellpadding="0"  cellspacing="0" align="center" style="width:25%">
<tr>
<td colspan="2" width="5"><b>Staff Members</b></td>
<td>
<select id="staff" name="staff">
  <option value="s1">Athiyamaan</option>
  <option value="s2">Pazhanivel</option>
  <option value="s3">Sampath</option>
  <option value="s4">Sundharamoorthy</option>
  <option value="s5">Karthik</option>	
  <option value="s6">Prabaharan</option>  
</select>
</td>		
</tr>
<tr>
<td colspan="2" width="5"><b>E-mail</b></td>
<td><input type="text" name="email" size="19" placeholder="Enter email ID" required>
</td></tr>
<tr>
<td colspan="2" width="5"><b>Comments</b></td>
<td><textarea id="msg" name="msg" rows="6" name="message" cols="20" required></textarea></td>
</tr>
<tr><td colspan="4" align="center">
<input type='submit' value='submit' name="submit"></td>
</tr>
<?php
if(isset($_POST['submit'])) {
$to = "rizwanamtech93@gmail.com";
$subject = "Remarks";
$name_field = $_POST['staff'];
$email_field = $_POST['email'];
$message = $_POST['message']; 
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
 
//echo "Data has been submitted to $to!";
$success = mail($to, $subject, $body,$headers);
} /*else {
echo "blarg!";
}*/
?>
</table><br><br>
</form>
</body>


What I have tried:

I had tried the above code and on button click the email is not been received and the page refreshes...i dont na where am wrong !! can anyone help me out
Posted
Updated 29-Feb-16 22:55pm
Comments
Richard MacCutchan 26-Feb-16 6:25am    
You do not check the return value to see if your mail call succeeded. Are you sure it went through all the code correctly?
alia007 26-Feb-16 6:55am    
i checked it but it just displays success msg wherein mail not received
Richard MacCutchan 26-Feb-16 6:57am    
What is the value returned by the mail command? If it says success, then there must be something else wrong, and the only way to find out is by using your debugger. It is impossible for anyone here to guess what happens when this code runs.
alia007 26-Feb-16 7:02am    
the user entered value is returned to the mail command.
alia007 26-Feb-16 6:59am    
i just need a sample code where the data in php goes into the inbox on button click.. can u help me with a succeded code .. if possible???

1 solution

Hi,

This code is working fine on Ubuntu, we have just configured the sendmail by following these instructions:

Getting the PHP mail() Function (sendmail) to Work on Ubuntu 14.04 | Luke Peters[^]

Hope this will work for you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900