M.O.S. Studios Posted September 15, 2008 Share Posted September 15, 2008 here is a script i wrote. it is basicly a form that sends out a value via email to every on on the db list. what i would like to do is make key words that are exchanged for dbs values. for example if the user types $name then i want the script to replace it with the name of the person sending reciving the email. any ideas?? include("../member.php"); include("../../common/link.php"); $send=mysql_query("SELECT * FROM mlist"); $amfail=0; $amsent=0; if($_POST['preview']!="Preview") { $text1="<textarea name='message' rows=8 cols=90%>"; $text2="</textarea>"; } if($_POST['send']=="Send!") { while(list($index,$to,$name)=mysql_fetch_array($send)) { $subject = "ATT: ".$name.". my NEWS Letter"; $message = stripslashes($_POST['message']); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); if(mail($to, $subject, $message, $headers)) {$amsent=$amsent+1;} else { $amfail=$amfail+1; $emails = $emails."<br>".$to." - ".$name; } } echo $amsent." E-mail(s) have been sent succsessfully<br>"; if($amfail>0){echo $amfail." E-mail(s) not sent.<br>failed emails:<br>".$emails;} } mysql_close($link); echo $tempvalue['top']; ?> <form method="POST" action="newmess.php"> <?php echo $text1.stripslashes($_POST['message']).$text2."<br>"; if($_POST['preview']!="Preview") {?> <input type="submit" name="preview" value="Preview"> <?php } else {?> <input type="hidden" value="<?php echo stripslashes($_POST['message']); ?>" name="message"> <input type="submit" value="Edit"> <?php } ?> <input type="submit" name="send" value="Send!"> </form> <?php echo $tempvalue['bottom']; ?> <a href="mail.php">Back to Mailing list options</a> / <a href="../account.php">Back to Main menu</a> Link to comment https://forums.phpfreaks.com/topic/124263-solved-replacing-values-from-a-form-post-with-values-from-a-db/ Share on other sites More sharing options...
rhyspaterson Posted September 15, 2008 Share Posted September 15, 2008 For the sanity of others (note: nothing has changed) include("../member.php"); include("../../common/link.php"); $send=mysql_query("SELECT * FROM mlist"); $amfail=0; $amsent=0; if($_POST['preview']!="Preview") { $text1="<textarea name='message' rows=8 cols=90%>"; $text2="</textarea>"; } if($_POST['send']=="Send!") { while(list($index,$to,$name)=mysql_fetch_array($send)) { $subject = "ATT: ".$name.". my NEWS Letter"; $message = stripslashes($_POST['message']); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); if(mail($to, $subject, $message, $headers)) {$amsent=$amsent+1;} else { $amfail=$amfail+1; $emails = $emails." ".$to." - ".$name; } } echo $amsent." E-mail(s) have been sent succsessfully "; if($amfail>0){echo $amfail." E-mail(s) not sent. failed emails: ".$emails;} } mysql_close($link); echo $tempvalue['top']; ?> <form method="POST" action="newmess.php"> <?php echo $text1.stripslashes($_POST['message']).$text2." "; if($_POST['preview']!="Preview") {?> <input type="submit" name="preview" value="Preview"> <?php } else {?> <input type="hidden" value="<?php echo stripslashes($_POST['message']); ?>" name="message"> <input type="submit" value="Edit"> <?php } ?> <input type="submit" name="send" value="Send!"> </form> <?php echo $tempvalue['bottom']; ?> <a href="mail.php">Back to Mailing list options[/url] / <a href="../account.php">Back to Main menu[/url] Link to comment https://forums.phpfreaks.com/topic/124263-solved-replacing-values-from-a-form-post-with-values-from-a-db/#findComment-641682 Share on other sites More sharing options...
M.O.S. Studios Posted September 15, 2008 Author Share Posted September 15, 2008 this is what i did i changed while(list($index,$to,$name)=mysql_fetch_array($send)) { $subject = "ATT: ".$name.". Love, Montreal NEWS Letter"; $message = stripslashes($tempvalue['top'].$_POST['message'].$tempvalue['bottom']); to this while(list($index,$to,$name)=mysql_fetch_array($send)) { $subject = "ATT: ".$name.". Love, Montreal NEWS Letter"; $message = stripslashes($tempvalue['top'].$_POST['message'].$tempvalue['bottom']); $message = str_replace("[name]",$name,$message); any one know how to make a scroll bar on this fourm?? thanks guys Link to comment https://forums.phpfreaks.com/topic/124263-solved-replacing-values-from-a-form-post-with-values-from-a-db/#findComment-641703 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.