Array data not displayed how needed....
Posted: Thu Feb 12, 2009 9:06 am
Hi i have a form which includes an list menu with various email addresses in. I would like to select 1 or multiple from the list and upon submitting it emails the results of the form to the emails selected.
I have the form in place and the contents go into the db fine, however the results of the email addresses chosen appear only as array. If i use serialize the email address(es) appear but with characters around them, with doesnt allow the mail to be sent. How can i with the code below clean this up so that the actual email addresses appear.
Please Help!
Add To Form Page
I won't add the code as just html but the name of the form element is emailto which i have made emailto[] because multiple...
Posted Form Data Page
Confirmed Data Page
Any help would be much appreciated..!!!
I have the form in place and the contents go into the db fine, however the results of the email addresses chosen appear only as array. If i use serialize the email address(es) appear but with characters around them, with doesnt allow the mail to be sent. How can i with the code below clean this up so that the actual email addresses appear.
Please Help!
Add To Form Page
I won't add the code as just html but the name of the form element is emailto which i have made emailto[] because multiple...
Posted Form Data Page
Code: Select all
<?php
$subject=$_POST['requiredsubject'];
$content=$_POST['requiredcontent'];
$date=$_POST['date'];
$email=$_POST['email'];
$postedby=$_POST['postedby'];
$time=$_POST['time'];
$type=$_POST['requiredtype'];
$emailto=$_POST['emailto'];
echo "<font face=Verdana size=1><b>Please confirm that the following is correct...</b><br>";
echo "<br><br><b>Subject:</b> $subject<br>";
echo "<br><br><b>Content:</b> $content<br>";
echo "<br><br><b>Type Of News:</b> $type<br>";
echo "<br><br><b>Send Email To:</b> $emailto<br>";
echo "<b><a href='confirm_news.php?subject=$subject&content=$content&type=$type&date=$date&time=$time&postedby=$postedby&email=$email&emailto=$emailto'>Yes</a> | <a href='#' onClick='history.go(-1)'>No</a></b></font>";
?>Code: Select all
<?php
$subject=$_GET['subject'];
$content=$_GET['content'];
$date=$_GET['date'];
$email=$_GET['email'];
$postedby=$_GET['postedby'];
$time=$_GET['time'];
$type=$_GET['type'];
$emailto=$_GET['emailto'];
include("login_details.inc");
mysql_connect ($dbhost, $dbuser, $dbpass) or die (mysql_error()); //Connects to database
//echo $dbhost. "<br/>";
//echo $dbuser. "<br/>";
//echo $dbpass. "<br/>";
//echo $dbname. "<br/>";
mysql_select_db ($dbname) or die (mysql_error()); //Selects your database
$query = "INSERT INTO news (subject, content, time, date, postedby, email, type)
VALUES ('$subject', '$content', '$time', '$date', '$postedby', '$email', '$type')";
//echo $query. "<br/>";
$result = mysql_query($query) or die("Error: ". mysql_error());
$to = $_GET['emailto'];
$subject = "Test - Please ignore";
$message = "<font face=Arial size=2>This is a test</font><br><br>" ;
$headers = "From: test@test.co.uk\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: text/html; charset=utf-8\r\n" .
"Content-Transfer-Encoding: 8bit\r\n\r\n";
if(mail($to, $subject, $message, $headers)){
echo"<font face=verdana size=1>Mail was sent to: $to</font>";
}else{
echo"<font face=verdana size=1>Sorry the email $to was bad</font>";
}
?>