Jump to content

[SOLVED] Form questions - How do I include or echo senders name in confirmation page


iconicCreator

Recommended Posts

Hello everyone,

New to PHP and just starting to learn things.

I have set up an e-mail, very basic, below is the code.

Everything appears to be working but I'm still learning.

 

I need the echo confirmation message that appears after the e-mail is submitted to contained the mail senders name.

 

Like this: Thanks Mariah for taking the time to participate in the evaluation, we will contact you within 24 hours.

 

Instead of this: Thanks for taking the time to participate in the evaluation, we will contact you within 24 hours.

 

Also, can anyone please tell me how I can style the echo message using html tags? Like how do I use the <p> or <h1> tag to format the echo confirmation message?

 

I'm am an advance CSS/Xhtml user but I don't know how to applied these tags within PHP echo.

 

Any ideas?

 

Thanks everyone. - IC

 

<?php

//FORM INPUT COLLECTION

$firstName = $_POST['firstName']; 
$lastName = $_POST['lastName']; 
$email = $_POST['email'];
$soupPreference = $_POST['soupPreference'];
$howMany = $_POST['howMany'];
$changes = $_POST['changes'];
$messageComments = $_POST['messageComments'];

//FORM PROCESSOR

$to = 'mymail.com';
$subject = 'Canned soup evaluation report';
$msg = "First Name: $firstName\n\n" .
       "Last Name: $lastName\n\n" .
       "E-Mail: $email\n\n" .
   "Do you like canned soup? $soupPreference\n\n" .
   "How many canned soup do you eat in a day? $howMany\n\n" .
   "What changes or suggestions would you recommend: $changes\n\n" .
   "Comments: $messageComments";
   
mail($to, $subject, $msg, 'from:' . $email);


echo  'Thanks for taking the time to participate in the evaluation, we will contact you within 24 hours.';

?>

 

You can use tags inside the quotation marks like echo "<b>text</b>";

 

Hey, thanks very, very much. It worked.

I would like to use CSS and style the echo string, like putting the message is a div tag and then styling it.

 

Any ideas?

 

IC

echo "<div id='style'>message</div>";

 

Something like that?

 

Basically I want to be able to wrapped the confirmation is a div tag. Then I can center the message, applied a background image  and so on. like this: <div id="confirmation">echo srting blah blah blah</div>

 

So from your example, I have to use only single quote around the div id name?

 

**Also, how would I do this if I want to apply a different style to the senders name using something like this: <p class="sendersName">Wyane</p> this way I can style the div tag and the senders name individually. How would all this go in a line of code?

 

Thanks a million

 

IC

it's simple, use the html tags to style your echo, don't forget to use quotes

 

example:

 

echo "<font size=\"2px\" face=\"tahoma\" color=\"red\">Thanks</font><font size=\"5px\" face=\"arial\" color=\"blue\"> $firstName</font> <font size=\"2px\" face=\"georgia\" color=\"black\">for taking the time to participate in the evaluation, we will contact you within 24 hours.</font>\n";

 

 

it's simple, use the html tags to style your echo, don't forget to use quotes

 

example:

 

echo "<font size=\"2px\" face=\"tahoma\" color=\"red\">Thanks</font><font size=\"5px\" face=\"arial\" color=\"blue\"> $firstName</font> <font size=\"2px\" face=\"georgia\" color=\"black\">for taking the time to participate in the evaluation, we will contact you within 24 hours.</font>\n";

 

I really appreciate your help and effort but the HTML tags you are refering to are "deprecated" meaning they are no longer recommended by the W3C and may create problems with XHTML.

 

I do not want to use font tags, I would rather use CSS to style the echo strings, this way I can completely separate the syle from the content.

 

IC

iconicCreator that was just an example to show you that you can put html into echo. so instead of <font> u can put what ever you like as far as i know

 

here is and example of something that i have and use it might help:

 

<div class="clearfix sBoxContent">

          <div class="clearfix sSearchBackground">

          <h3><?php echo array_search($type, $array); ?> <?php echo $ds[8]; ?></h3>

        <fieldset id="sSearch">

 

now if you want to output that message from your form and put it into a div, i'll try to help, using the code from you

 

<?php

//FORM INPUT COLLECTION

$firstName = $_POST['firstName']; 
$lastName = $_POST['lastName']; 
$email = $_POST['email'];
$soupPreference = $_POST['soupPreference'];
$howMany = $_POST['howMany'];
$changes = $_POST['changes'];
$messageComments = $_POST['messageComments'];

//FORM PROCESSOR

$to = 'mymail.com';
$subject = 'Canned soup evaluation report';
$msg = "First Name: $firstName\n\n" .
       "Last Name: $lastName\n\n" .
       "E-Mail: $email\n\n" .
      "Do you like canned soup? $soupPreference\n\n" .
      "How many canned soup do you eat in a day? $howMany\n\n" .
      "What changes or suggestions would you recommend: $changes\n\n" .
      "Comments: $messageComments";
      
mail($to, $subject, $msg, 'from:' . $email);

$msgecho = "Thanks $firstName for taking the time to participate in the evaluation, we will contact you within 24 hours.";

?>

and put this row where you need to output the echo:

<?php echo $msgecho; ?>

iconicCreator that was just an example to show you that you can put html into echo. so instead of <font> u can put what ever you like as far as i know

 

here is and example of something that i have and use it might help:

 

<div class="clearfix sBoxContent">

          <div class="clearfix sSearchBackground">

          <h3><?php echo array_search($type, $array); ?> <?php echo $ds[8]; ?></h3>

        <fieldset id="sSearch">

 

now if you want to output that message from your form and put it into a div, i'll try to help, using the code from you

 

<?php

//FORM INPUT COLLECTION

$firstName = $_POST['firstName']; 
$lastName = $_POST['lastName']; 
$email = $_POST['email'];
$soupPreference = $_POST['soupPreference'];
$howMany = $_POST['howMany'];
$changes = $_POST['changes'];
$messageComments = $_POST['messageComments'];

//FORM PROCESSOR

$to = 'mymail.com';
$subject = 'Canned soup evaluation report';
$msg = "First Name: $firstName\n\n" .
       "Last Name: $lastName\n\n" .
       "E-Mail: $email\n\n" .
      "Do you like canned soup? $soupPreference\n\n" .
      "How many canned soup do you eat in a day? $howMany\n\n" .
      "What changes or suggestions would you recommend: $changes\n\n" .
      "Comments: $messageComments";
      
mail($to, $subject, $msg, 'from:' . $email);

$msgecho = "Thanks $firstName for taking the time to participate in the evaluation, we will contact you within 24 hours.";

?>

and put this row where you need to output the echo:

<?php echo $msgecho; ?>

 

I'm not trying to be arrogant but the truth is I'm very new to PHP, infact, after months of reading dead end books, I was finally able to create this little form script.

Because of my ignorance to PHP, I want to make sure I'm learning thins the right way.

 

However, I really appreciate you taking the time to help me learn PHP.

 

What I am trying to do is add style to the confirmation page or string.

 

Eg: wrapped the entire message in a div tag but apply individual style to the senders name if I needed to.

 

But I will try your suggestions and let you know how this work.

 

IC

You can enter in and out of php at will, though if you do it too much, it can make your code confusing. But for example, you can step out of php code to do html like this:

 

$to = 'mymail.com';
$subject = 'Canned soup evaluation report';
$msg = "First Name: $firstName\n\n" .
       "Last Name: $lastName\n\n" .
       "E-Mail: $email\n\n" .
      "Do you like canned soup? $soupPreference\n\n" .
      "How many canned soup do you eat in a day? $howMany\n\n" .
      "What changes or suggestions would you recommend: $changes\n\n" .
      "Comments: $messageComments";
      
mail($to, $subject, $msg, 'from:' . $email);

?>

<p>Thanks for taking the time to participate in the evaluation, we will contact you within 24 hours.</p>

<?php
  // do some more stuff here
?>

 

or you can exit php in 'if' statements, to put HTML inside:

 

<?php
if($something == 'else')
{
?>

<p> you will only see this if the value of $something is 'else'

<?php
}
?>

 

Or you can enter php into HTML:

 

<?php
$name = 'Mary';
?>

<p>Hello <?php echo $name; ?></p>

 

The above will print 'Hello Mary' to the screen.

 

It can be difficult to read HTML when it's part of an echo statement, making it easy to have errors, so I generally prefer to exit php for my HTML statements, and just add php inside if necessary, using the third method I showed.

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.