Jump to content

[SOLVED] replacing values from a form post with values from a db


M.O.S. Studios

Recommended Posts

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>

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]

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.