invision
03-11-2006, 09:47 AM
I'm sure this is quite a simple problem, but here goes.
I want it to say Dear 'username' in the email. Right now it just is 'Dear ,'
Any ideas ?
<?php # - mail_out.php
// This is the mail_out page for Pictures of Scotland admin to email members if they are 'subscribed' to the mailing list.
// Inclyde the configuration file for error management again
require_once ('../includes/config.inc.php');
require_once('../../mysql_connect.php');
$page_title = "Send a Mail Out!";
include ('../includes/aheader.html');
if (($_SESSION['user_id']=='1')) {
if (isset($_POST['submitted'])) { // Handle the form.
$query = "SELECT users.username, users.email, pid FROM users, profiles WHERE profiles.maillist='Y' AND users.user_id = pid";
$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
$row = mysql_fetch_array($result);
if (mysql_num_rows($result) != 0) {
// if it ran OK
$usern = $row['username'];
// Send the email.
$body = "Dear: ".$usern.",\n\n";
$body.= $_POST['mail_out'];
while ($row = mysql_fetch_array($result)) {
if (empty($_POST['mail_out'])) {
echo '<a href="javascript:history.go(-1)">Please insert your message to those on the mailing list, Thank you.</a>';
} else {
mail($row['email'], 'Pictures of Scotland Newsletter', stripslashes($body), 'From:Pictures of Scotland<mm021135@student.paisley.ac.uk>');
}
// Finish the page
echo '<H3>Your mail-out has been sent successfully to those on the Mailing List.</h3>';
include ('../includes/afooter.html'); // Include the HTML footer.
exit();
}
mysql_close(); // Close the connection with the Database
}
} // End of the main Submit conditional.
?> <h2>Mailing List</h2>
<p>Type in a message below to be sent to everyone on the mailing list.</p><form action="mail_out.php" method="post"><p><b>Enter Mail Out here :</b><br><textarea name="mail_out" COLS="60" ROWS="8"></textarea></p>
<div align="center"><input type="submit" class="submit" name="submit" value="Send Mail Out" /></div>
<input type="hidden" name="submitted" value="TRUE"/>
</form>
<?php
}
else {
echo '<p>Sorry, you need to be admin to enter this area.<br />';
echo '<b>Options :</b>';
echo '<ul><li><a href="javascript:history.go(-1)">Go back to the previous page</a></li>';
echo '<li><a href="login.php">Login</a></li>';
echo '<li><a href="register.php">Register</a></li>';
echo '<li><a href="forgot_password.php">Forgot Password</a></li>';
}
include ('../includes/afooter.html');
?>
Many thanks once more for taking a look-see.
I want it to say Dear 'username' in the email. Right now it just is 'Dear ,'
Any ideas ?
<?php # - mail_out.php
// This is the mail_out page for Pictures of Scotland admin to email members if they are 'subscribed' to the mailing list.
// Inclyde the configuration file for error management again
require_once ('../includes/config.inc.php');
require_once('../../mysql_connect.php');
$page_title = "Send a Mail Out!";
include ('../includes/aheader.html');
if (($_SESSION['user_id']=='1')) {
if (isset($_POST['submitted'])) { // Handle the form.
$query = "SELECT users.username, users.email, pid FROM users, profiles WHERE profiles.maillist='Y' AND users.user_id = pid";
$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
$row = mysql_fetch_array($result);
if (mysql_num_rows($result) != 0) {
// if it ran OK
$usern = $row['username'];
// Send the email.
$body = "Dear: ".$usern.",\n\n";
$body.= $_POST['mail_out'];
while ($row = mysql_fetch_array($result)) {
if (empty($_POST['mail_out'])) {
echo '<a href="javascript:history.go(-1)">Please insert your message to those on the mailing list, Thank you.</a>';
} else {
mail($row['email'], 'Pictures of Scotland Newsletter', stripslashes($body), 'From:Pictures of Scotland<mm021135@student.paisley.ac.uk>');
}
// Finish the page
echo '<H3>Your mail-out has been sent successfully to those on the Mailing List.</h3>';
include ('../includes/afooter.html'); // Include the HTML footer.
exit();
}
mysql_close(); // Close the connection with the Database
}
} // End of the main Submit conditional.
?> <h2>Mailing List</h2>
<p>Type in a message below to be sent to everyone on the mailing list.</p><form action="mail_out.php" method="post"><p><b>Enter Mail Out here :</b><br><textarea name="mail_out" COLS="60" ROWS="8"></textarea></p>
<div align="center"><input type="submit" class="submit" name="submit" value="Send Mail Out" /></div>
<input type="hidden" name="submitted" value="TRUE"/>
</form>
<?php
}
else {
echo '<p>Sorry, you need to be admin to enter this area.<br />';
echo '<b>Options :</b>';
echo '<ul><li><a href="javascript:history.go(-1)">Go back to the previous page</a></li>';
echo '<li><a href="login.php">Login</a></li>';
echo '<li><a href="register.php">Register</a></li>';
echo '<li><a href="forgot_password.php">Forgot Password</a></li>';
}
include ('../includes/afooter.html');
?>
Many thanks once more for taking a look-see.