0

Hi everyone. I have made a mailing list script but I want to modify it so that I can post some variables in the message box.

I would like something like this.

To display something like this.


I have tried putting

' . $fetch['first'] . '


and

$fetch['first']


in the message box put it just prints out what i have typed.

Please could I get some help because this is really annoying me.

Thanks in advance.

Attachments Capture.JPG 22 KB Capture2.JPG 19.72 KB
4
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by doctorphp
0

mailing_list.php

<form name="mailing_list" action="mailing_list_send.php" method="post">

			 	<table>

                	<thead>

                        <tr>

                            <th width="15%">Send To</th>

                            <th>:</th>

                            <th>
							<?php
							$mailcount = 0;
							$namecount = 0;
							$get = mysql_query("SELECT * FROM users WHERE adminemails='1'");
							while($getrow = mysql_fetch_assoc($get))
							{
								echo '<input type="checkbox" name="mail_' . $mailcount++ . '" value="' . $getrow['email'] . '" checked /> ' . $getrow['username'] . ' (' . $getrow['email'] . ')<br />';
   echo '<input type="hidden" name="name_' . $namecount++ . '" value="' . $getrow['username'] . '" />';
							}
							?>
                            </th>

                        </tr>

                        <tr>

                            <th width="15%">Subject</th>

                            <th>:</th>

                            <th><input type="text" name="subject" id="subject" class="text-input" /></th>

                        </tr>

                        </thead>

                        </table>

                        <table>

                        <thead>

                        <tr>

                            <th>

                            Message

                            <textarea rows="6" name="messageuser" id="messageuser"></textarea>

                            </th>

                        </tr>

                        <tr>

                            <th width="15%"><input type="submit" name="send" value="Send" class="button" /></th>

                            <th>&nbsp;</th>

                            <th>&nbsp;</th>

                        </tr>

                    </thead>

                </table>

                </form>

mailing_list_send.php

<?php
require '../connect.php';

if(isset($_POST['send']))
{

for($x=0;$x<$_POST;$x++)
{
  if ($_POST['mail_' . $x . ''])
  {
		$to = $_POST['mail_' . $x . ''];
		
		$subject = $_POST['subject'];
		
		$message = $_POST['messageuser'];
		
		$body = '
		<html>
		<head>
		<style type="text/css">
		body {
		font-family: Arial, Helvetica, sans-serif;
		font-size: 16px;
		}	
		
		.bold {
		font-weight: bold;
		}
		</style>
		<title>' . $subject . '</title>
		</head>
		
		<body>
		' . $message . '
		</body>
		</html>
		';
		
		// Always set content-type when sending HTML email
		$headers = "MIME-Version: 1.0" . "\r\n";
		$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
		
		// More headers
		$headers .= 'From: Mega Instrumentals <notifications@megainstrumentals.co.uk>' . "\r\n";
		
		$mail = mail($to, $subject, $body, $headers);
		
		if($mail)
		{
			header('location: mailing_list.php?send=1');
		}
		else
		if(!$mail)
		{
			header('location: mailing_list.php?send=0');
		}
  }
}
}
?>
0

THis isn't a solution, but how about separating your php and html. Mixing them like this makes for messy code. I'd place all data into variables and then echo out the variables in the appropriate place. That should tidy up things.

0

Can you explain where your actual problem is? And we can help you out accordingly. Because what you are actually doing there is saying that you want something but we do not know your problem.

0

I am trying to make an email form where my admins and staff can email multiple users and they can type something like %username% and it will display the username of the user. I have tried $fetch but it just prints that out in the email.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.