Forum Moderators: coopster

Message Too Old, No Replies

re: implode, how to print results of $ Post on separate lines

         

oneofmany

4:06 pm on Aug 9, 2006 (gmt 0)

10+ Year Member



Hi.
I would like to have the the results of the following print on separate lines because right now what doesn't fit on one line gets cut off! (so if someone using this form registers for more than 3 events, which I hope they will, I won't get the events they registered for beyond the first 3.)

echo "<p>Thank you,$_POST[Registrant],for your registration!</p><p>You will receive confirmation of your registration details in the mail.";
$msg .= "InstitutionName: $_POST[InstitutionName]\n";
$msg .= "Address: $_POST[Address]\n";
$msg .= "City: $_POST[City]\n";
$msg .= "State: $_POST[State]\n";
$msg .= "Zip: $_POST[Zip]\n";
$msg .= "Registrant : $_POST[Registrant]\n";
$msg .= "Title: $_POST[Title]\n";
$msg .= "Telephone: $_POST[Telephone]\n";
$msg .= "Fax: $_POST[Fax]\n";
$msg .= "Email: $_POST[Email]\n";
$fairs = (!empty($_POST['CCfair'])? implode(',',$_POST['CCfair'])."\n" : '');
$msg .= 'CCfair: '.$fairs.'\n';
$recipient = "";
$subject = "";
$mailheaders = "from: $_POST[Registrant]\n";
$mailheaders = "Reply-to: $_POST[Email]\n";
mail($recipient, $subject, $msg, $mailheaders);

dreamcatcher

8:58 am on Aug 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi oneofmany,

Sorry, I`m a little unclear of what you are asking. What is getting cut off and where? Can you give a little bit more info please?

dc

FiRe

9:06 am on Aug 10, 2006 (gmt 0)

10+ Year Member



$fairs = (!empty($_POST['CCfair'])) ? implode("\n", $_POST['CCfair']) : '';
$msg .= "CCfair: ".$fairs."\n";

[edited by: FiRe at 9:08 am (utc) on Aug. 10, 2006]

oneofmany

5:55 pm on Aug 12, 2006 (gmt 0)

10+ Year Member



Apologies, dc, the error was in my form (typo) and not the php code! I have two issues, however, I hope you can help me resolve.
The important one: Everything worked very nicely until I tried to work some html on the php page and I split the one php script into two -I had hoped to have the page that has the response message look like the other pages in the site but still perform the php functions, but now that it does, I've lost the functionality of the email msg?! (I'm not getting the info in the email as I was.) Is this because there are two php scripts? Below is the code. Thanks again for all of the insights!

<title>Untitled Document</title>
<link href="ccnhcfstyle.css" rel="stylesheet" type="text/css" media="screen" />
</head>

<body>
<?php
$msg .= "InstitutionName: $_POST[InstitutionName]\n";
$msg .= "Address: $_POST[Address]\n";
$msg .= "City: $_POST[City]\n";
$msg .= "State: $_POST[State]\n";
$msg .= "Zip: $_POST[Zip]\n";
$msg .= "Registrant : $_POST[Registrant]\n";
$msg .= "Title: $_POST[Title]\n";
$msg .= "Telephone: $_POST[Telephone]\n";
$msg .= "Fax: $_POST[Fax]\n";
$msg .= "Email: $_POST[Email]\n";
$fairs = (!empty($_POST['CCfair'])? implode(',',$_POST['CCfair'])."\n" : '');
$msg .= 'CCfair: '.$fairs.'\n';
$recipient = "";
$subject = "CC Fairs form submission results";
$mailheaders = "from: $_POST[Registrant]\n";
$mailheaders = "Reply-to: $_POST[Email]\n";
mail($recipient, $subject, $msg, $mailheaders);
?>
<div id="wrap">
<div id="wrap-inner">
<div id="header">
<img src="whitecap.gif" alt="logo" width="80" height="80" /><h1>collegefair.info by <br />
CAREER COUNCIL &amp; NATIONAL HISPANIC COLLEGE FAIRS</h1>
<p id="topnav"><a href="file:///Macintosh HD/webroot/collegefair.info">home</a> ¦ <a href="#">contact</a> ¦ <a href="#">site map</a></p>
</div>
<div id="main-body">
<div id="sidebar">
<div id="sidebarDiv">
<h3>EXPLORE OUR SITE </h3>
<p><a href="AboutCC/NHCF.html">About CC/NHCF</a></p>
<p><a href="CCRegistration.html">Career Council College Fairs</a></p>
<p><a href="NHCFRegistration.html">National Hispanic College Fairs</a></p>
<p><a href="Locations.html">Locations</a></p>
<p><span class="style14">Each day, Over 2,000 College-Bound High School Seniors will be there.....<br />
WILL YOU? </span></p>
<h4>&nbsp;</h4>
</div>
</div>
<div id="content">
<div id="contentDiv">
<p align="center">Thank you,<?php echo $_POST['Registrant'];?>, for your registration. <br />

oneofmany

6:17 pm on Aug 12, 2006 (gmt 0)

10+ Year Member



Ah, the second issue...which is actually the first I sought guidance on, how does one have checkbox form results, collected in an array, print on separate lines?

<?php
$msg .= "InstitutionName: $_POST[InstitutionName]\n";
$msg .= "Address: $_POST[Address]\n";
$msg .= "City: $_POST[City]\n";
$msg .= "State: $_POST[State]\n";
$msg .= "Zip: $_POST[Zip]\n";
$msg .= "Registrant : $_POST[Registrant]\n";
$msg .= "Title: $_POST[Title]\n";
$msg .= "Telephone: $_POST[Telephone]\n";
$msg .= "Fax: $_POST[Fax]\n";
$msg .= "Email: $_POST[Email]\n";
$fairs = (!empty($_POST['CCfair'])? implode(',',$_POST['CCfair'])."\n" : '');
$msg .= 'CCfair: '.$fairs.'\n';
$recipient = "chriscanning@optonline.net";
$subject = "Career Council College Fairs form submission results";
$mailheaders = "from: $_POST[Registrant]\n";
$mailheaders = "Reply-to: $_POST[Email]\n";
mail($recipient, $subject, $msg, $mailheaders);
?>
Right now, the results will print something like this in the email (which I hope to restore receipt of!) that is generated:
CCFair: CC_AtlantaGA, CC_NewYorkNY, CC_HollywoodFL,CC_HoustonTX,CC_AkronOH,
I think it would be more legible for those following up on this input if it printed like:
CC_AtlantaGA
CC_New York,
CC_HollywoodFL
CC_HoustonTX
CC_AkronOH
because registrants may sign up for as many as 22 events.
Thank you!

dreamcatcher

7:28 am on Aug 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need a foreach loop:


$msg .= 'CCfair: "\n\n";

if (!empty($_POST['CCfair']))
{
foreach ($_POST['CCfair'] AS $fair)
{
$msg .= $fair."\n";
}
}

dc

oneofmany

5:11 am on Aug 17, 2006 (gmt 0)

10+ Year Member




System: The following message was spliced on to this thread from: http://www.webmasterworld.com/php/3049415.htm [webmasterworld.com] by dreamcatcher - 7:35 am on Aug. 17, 2006 (utc 0)


THANK YOU DC!