Search the Community
Showing results for tags 'email info from db'.
-
Good Morning, I am building a system at work with Mysql and PHP with regards to log-in's and submitting information. I need to send the form info to my Database (which works great) but now I have to send the information that was submitted into the Databse to the applicable users email address, this user then has to click a link in the mail to take him/her to continue. I am struggling horribly with the email function.. Here is my code that I am using: <?php $conn = mysql_connect("localhost","root","root"); $db = mysql_select_db("mysql",$conn); ?> <?php $alloc = $_POST["alloc"]; $allocby = $_POST["allocby"]; $specification = $_POST["specification"]; $reqno = $_POST["reqno"]; $scheme = $_POST["scheme"]; $fromtime = $_POST["fromtime"]; $totime = $_POST["totime"]; $targetdate = $_POST["targetdate"]; $comments = $_POST["comments"]; if($alloc == "s"){ $alloc = 'MHAS002 - AS'; }else if ($alloc == "t"){ $alloc = 'MHMS004 - SM'; }else if ($alloc == "u"){ $alloc = 'MHMN005 - MM'; }else if ($alloc =="v"){ $alloc = 'MHMW005 - MVW'; }else if ($alloc == "w"){ $alloc = 'MHGC001 - GC'; }else if ($alloc == "x"){ $alloc = 'MHGK002 - GDP'; }else if ($alloc == "y"){ $alloc = 'MHLW009 - LW'; }else if ($alloc == "z"){ $alloc = 'MHZP001 - ZP'; }; if($allocby == "a"){ $allocby = 'LM; }else if ($allocby == "b"){ $allocby = 'User'; }else if ($allocby == "c"){ $allocby = 'Other'; }; $sql = "INSERT into manspecification values('$alloc','$allocby','$specification','$reqno','$scheme','$fromtime','$totime','$targetdate','$comments')"; $query = mysql_query($sql); if(!$query) echo mysql_error(); else { echo "Successfully Inserted<br />"; } $to = "johnny@johnny.co.za"; $subject = "Specification"; $email = $_POST['Email']; $message = $_POST['Spec']; $headers = "From: [email="$johnny@gmail.com"]$johnny@gmail.com[/email]"; $sent = mail($to, $subject, $message, $headers); if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } ?> <p> </p> <table border="0" cellspacing="0" cellpadding="3"> <tr><td> Allocated To: <td> <?=$alloc?> <tr><td> Allocated By: <td> <?=$allocby?> <tr><td> Spec Info: <td> <?=$type?> <tr><Td> Request No: <td> <?=$reqno?> <tr><td> Scheme: <td> <?=$scheme?> <tr><td> From Time: <td> <?=$fromtime?> <tr><td> To Time: <td> <?=$totime?> <tr><td> Target Date: <td> <?=$targetdate?> <tr><td> Comments: <td> <?=$comments?> <td> <td> </td> </table> </form> <p><A HREF="/manspesifications.html" target="_self"><strong>Go back</strong></A></p> </body> </html> I would apprecaite any help with this as this would be the first time that I am working with php and not to mention emails in phph *blush* :'(