Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-07-2011, 06:44 PM   PM User | #1
sjaban
New to the CF scene

 
Join Date: Apr 2011
Posts: 7
Thanks: 3
Thanked 1 Time in 1 Post
sjaban is an unknown quantity at this point
Send a Copy to Yourself in contact form

I'll make a line to my contact form like (Send copy to yourself), how can I do that?
Thank you for your hand

here's my PHP code:

<?php
$mailTo = 'contact@site.com';
$name = htmlspecialchars($_POST['Name']);
$mailFrom = htmlspecialchars($_POST['Email']);
$telefon = htmlspecialchars($_POST['Telefon']);
$adresse = htmlspecialchars($_POST['Adresse']);
$subject = htmlspecialchars($_POST['Subject']);
$message_text = htmlspecialchars($_POST['Message']);
$header = "From: ". $name . " <" . $mailFrom . ">\r\n";
$header .= "Content-Type: text/plain; charset=\"UTF-8\"";


$message = 'Navn: '.$name.'
E-post: '.$mailFrom.'
Telefon: '.$telefon.'
Adresse: '.$adresse.'
Melding: '.$message_text;

mail($mailTo, $subject, $message, $header);
?>

_______________________________________________________________

Here is HTML code:

<!-- contact-form START here -->
<div id="feedback">
<p class="error wrong_name"> - Vennligst skriv inn ditt navn.</p>
<p class="error wrong_email"> - Vennligst skriv inn din e-postadresse.</p>
<p class="error wrong_message"> - Vennligst skriv inn din melding.</p>
</div>
<form action="sendemail.php" id="contact_us" method="post">
<p class="label_name">Navn</p>
<p class="input_form">
<input type="text" name="Name" />
</p>
<p class="label_name">E-post</p>
<p class="input_form">
<input type="text" name="Email" />
</p>
<p class="label_name">Telefon</p>
<p class="input_form">
<input type="text" name="Telefon" />
</p>
<p class="label_name">Adresse</p>
<p class="input_form">
<input type="text" name="Adresse" />
</p>
<p class="label_name">Emne</p>
<p class="input_form">
<input type="text" name="Subject" />
</p>
<p class="label_name">Melding</p>
<p class="input_form" id="textarea">
<textarea name="Message" rows="10" cols="4" id="message_input"></textarea>
</p>
<p id="submit">
<input type="submit" value="Send" name="submitButton" class="button" />
</p>
</form>
<p id="success">Takk. Din melding ble sendt. Vi vil besvare din henvendelse så fort som mulig.</p>
<!-- contact-form END here -->

_______________________________________________________________

Example: http://bildr.no/view/858937


Thank you for help
sjaban is offline   Reply With Quote
Users who have thanked sjaban for this post:
dylan75 (04-11-2011)
Old 04-07-2011, 07:21 PM   PM User | #2
tropane
New Coder

 
Join Date: Nov 2010
Location: United Kingdom
Posts: 31
Thanks: 0
Thanked 9 Times in 8 Posts
tropane is an unknown quantity at this point
use [PHP] tags next time and try this (havent checked):
PHP:
PHP Code:
<?php
//Send copy - Start
$copy 0;
$copy mysql_real_escape_string($_POST['copy']);
if(
$copy == 1)
{
$mailTo htmlspecialchars($_POST['Email']);
$name htmlspecialchars($_POST['Name']);
$mailFrom htmlspecialchars($_POST['Email']);
$telefon htmlspecialchars($_POST['Telefon']);
$adresse htmlspecialchars($_POST['Adresse']);
$subject htmlspecialchars($_POST['Subject']);
$message_text htmlspecialchars($_POST['Message']);
$header "From: "$name " <" $mailFrom ">\r\n";
$header .= "Content-Type: text/plain; charset=\"UTF-8\"";


$message 'Navn: '.$name.'
E-post: '
.$mailFrom.'
Telefon: '
.$telefon.'
Adresse: '
.$adresse.'
Melding: '
.$message_text;

mail($mailTo$subject$message$header);
}
//Send copy -End

$mailTo 'contact@site.com';
$name htmlspecialchars($_POST['Name']);
$mailFrom htmlspecialchars($_POST['Email']);
$telefon htmlspecialchars($_POST['Telefon']);
$adresse htmlspecialchars($_POST['Adresse']);
$subject htmlspecialchars($_POST['Subject']);
$message_text htmlspecialchars($_POST['Message']);
$header "From: "$name " <" $mailFrom ">\r\n";
$header .= "Content-Type: text/plain; charset=\"UTF-8\"";


$message 'Navn: '.$name.'
E-post: '
.$mailFrom.'
Telefon: '
.$telefon.'
Adresse: '
.$adresse.'
Melding: '
.$message_text;

mail($mailTo$subject$message$header);
?>
HTML:
Code:
<!-- contact-form START here -->
<div id="feedback">
<p class="error wrong_name"> - Vennligst skriv inn ditt navn.</p>
<p class="error wrong_email"> - Vennligst skriv inn din e-postadresse.</p>
<p class="error wrong_message"> - Vennligst skriv inn din melding.</p>
</div>
<form action="sendemail.php" id="contact_us" method="post">
<p class="label_name">Navn</p>
<p class="input_form">
<input type="text" name="Name" />
</p>
<p class="label_name">E-post</p>
<p class="input_form">
<input type="text" name="Email" />
</p>
<p class="label_name">Telefon</p>
<p class="input_form">
<input type="text" name="Telefon" />
</p>
<p class="label_name">Adresse</p>
<p class="input_form">
<input type="text" name="Adresse" />
</p>
<p class="label_name">Emne</p>
<p class="input_form">
<input type="text" name="Subject" />
</p>
<p class="label_name">Melding</p>
<p class="input_form" id="textarea">
<textarea name="Message" rows="10" cols="4" id="message_input"></textarea>
</p>
<p class="label_name">Send yourself a copy</p>
<p class="input_form">
<input type="checkbox" name="copy" value="1" /> 
</p>
<p id="submit">
<input type="submit" value="Send" name="submitButton" class="button" />
</p>
</form>
<p id="success">Takk. Din melding ble sendt. Vi vil besvare din henvendelse så fort som mulig.</p>
<!-- contact-form END here -->
tropane is offline   Reply With Quote
Users who have thanked tropane for this post:
sjaban (04-07-2011)
Old 04-07-2011, 07:56 PM   PM User | #3
sjaban
New to the CF scene

 
Join Date: Apr 2011
Posts: 7
Thanks: 3
Thanked 1 Time in 1 Post
sjaban is an unknown quantity at this point
Quote:
Originally Posted by tropane View Post
use [PHP] tags next time and try this (havent checked):
PHP:
PHP Code:
<?php
//Send copy - Start
$copy 0;
$copy mysql_real_escape_string($_POST['copy']);
if(
$copy == 1)
{
$mailTo htmlspecialchars($_POST['Email']);
$name htmlspecialchars($_POST['Name']);
$mailFrom htmlspecialchars($_POST['Email']);
$telefon htmlspecialchars($_POST['Telefon']);
$adresse htmlspecialchars($_POST['Adresse']);
$subject htmlspecialchars($_POST['Subject']);
$message_text htmlspecialchars($_POST['Message']);
$header "From: "$name " <" $mailFrom ">\r\n";
$header .= "Content-Type: text/plain; charset=\"UTF-8\"";


$message 'Navn: '.$name.'
E-post: '
.$mailFrom.'
Telefon: '
.$telefon.'
Adresse: '
.$adresse.'
Melding: '
.$message_text;

mail($mailTo$subject$message$header);
}
//Send copy -End

$mailTo 'contact@site.com';
$name htmlspecialchars($_POST['Name']);
$mailFrom htmlspecialchars($_POST['Email']);
$telefon htmlspecialchars($_POST['Telefon']);
$adresse htmlspecialchars($_POST['Adresse']);
$subject htmlspecialchars($_POST['Subject']);
$message_text htmlspecialchars($_POST['Message']);
$header "From: "$name " <" $mailFrom ">\r\n";
$header .= "Content-Type: text/plain; charset=\"UTF-8\"";


$message 'Navn: '.$name.'
E-post: '
.$mailFrom.'
Telefon: '
.$telefon.'
Adresse: '
.$adresse.'
Melding: '
.$message_text;

mail($mailTo$subject$message$header);
?>
HTML:
Code:
<!-- contact-form START here -->
<div id="feedback">
<p class="error wrong_name"> - Vennligst skriv inn ditt navn.</p>
<p class="error wrong_email"> - Vennligst skriv inn din e-postadresse.</p>
<p class="error wrong_message"> - Vennligst skriv inn din melding.</p>
</div>
<form action="sendemail.php" id="contact_us" method="post">
<p class="label_name">Navn</p>
<p class="input_form">
<input type="text" name="Name" />
</p>
<p class="label_name">E-post</p>
<p class="input_form">
<input type="text" name="Email" />
</p>
<p class="label_name">Telefon</p>
<p class="input_form">
<input type="text" name="Telefon" />
</p>
<p class="label_name">Adresse</p>
<p class="input_form">
<input type="text" name="Adresse" />
</p>
<p class="label_name">Emne</p>
<p class="input_form">
<input type="text" name="Subject" />
</p>
<p class="label_name">Melding</p>
<p class="input_form" id="textarea">
<textarea name="Message" rows="10" cols="4" id="message_input"></textarea>
</p>
<p class="label_name">Send yourself a copy</p>
<p class="input_form">
<input type="checkbox" name="copy" value="1" /> 
</p>
<p id="submit">
<input type="submit" value="Send" name="submitButton" class="button" />
</p>
</form>
<p id="success">Takk. Din melding ble sendt. Vi vil besvare din henvendelse så fort som mulig.</p>
<!-- contact-form END here -->
Thank you dear tropane
But not working, copy not going to sender :-(
help pleas.
sjaban is offline   Reply With Quote
Old 04-07-2011, 09:51 PM   PM User | #4
sjaban
New to the CF scene

 
Join Date: Apr 2011
Posts: 7
Thanks: 3
Thanked 1 Time in 1 Post
sjaban is an unknown quantity at this point
Quote:
Originally Posted by sjaban View Post
Thank you dear tropane
But not working, copy not going to sender :-(
help pleas.
Anybody can help me please
sjaban is offline   Reply With Quote
Old 04-07-2011, 11:55 PM   PM User | #5
BoyWander
New Coder

 
Join Date: Mar 2011
Posts: 62
Thanks: 3
Thanked 2 Times in 2 Posts
BoyWander is an unknown quantity at this point
If it sends to everybody but yourself, why don't you just include yourself in the mailing list??
BoyWander is offline   Reply With Quote
Old 04-08-2011, 12:10 AM   PM User | #6
tropane
New Coder

 
Join Date: Nov 2010
Location: United Kingdom
Posts: 31
Thanks: 0
Thanked 9 Times in 8 Posts
tropane is an unknown quantity at this point
hmm, try this :P
PHP Code:
$mailTo "contact@site.com, mysql_real_escape_string($_POST['Email'])"
tropane is offline   Reply With Quote
Old 04-08-2011, 03:05 PM   PM User | #7
sjaban
New to the CF scene

 
Join Date: Apr 2011
Posts: 7
Thanks: 3
Thanked 1 Time in 1 Post
sjaban is an unknown quantity at this point
Quote:
Originally Posted by tropane View Post
hmm, try this :P
PHP Code:
$mailTo "contact@site.com, mysql_real_escape_string($_POST['Email'])"
Hello

I do misunderstand, I like to say that, for example from the site contact form, you (or Sender) send an e-mail to me and sent a copy of the email to you (avsendr limbs) as well.
not contact@site.com.
Hope explained well enough :-)
(Post going to contact@site.com but not going CC to sender problem is sender copy not working)
Thanx for help

Last edited by sjaban; 04-08-2011 at 03:52 PM..
sjaban is offline   Reply With Quote
Old 04-08-2011, 08:35 PM   PM User | #8
tropane
New Coder

 
Join Date: Nov 2010
Location: United Kingdom
Posts: 31
Thanks: 0
Thanked 9 Times in 8 Posts
tropane is an unknown quantity at this point
oh, I've mad a mistake in my code now... it should work..
PHP Code:
<?php
if(isset($_POST['copy']) && $_POST['copy'] == 1)
{
$mailTo htmlspecialchars($_POST['Email']);
$name htmlspecialchars($_POST['Name']);
$mailFrom htmlspecialchars($_POST['Email']); 
$telefon htmlspecialchars($_POST['Telefon']); 
$adresse htmlspecialchars($_POST['Adresse']); 
$subject htmlspecialchars($_POST['Subject']);
$message_text htmlspecialchars($_POST['Message']); 
$header "From: "$name " <" $mailFrom ">\r\n";
$header .= "Content-Type: text/plain; charset=\"UTF-8\"";


$message 'Navn: '.$name.
E-post: '
.$mailFrom.
Telefon: '
.$telefon.
Adresse: '
.$adresse.
Melding: '
.$message_text;

mail($mailTo$subject$message$header);
}

$mailTo 'contact@site.com';
$name htmlspecialchars($_POST['Name']);
$mailFrom htmlspecialchars($_POST['Email']); 
$telefon htmlspecialchars($_POST['Telefon']); 
$adresse htmlspecialchars($_POST['Adresse']); 
$subject htmlspecialchars($_POST['Subject']);
$message_text htmlspecialchars($_POST['Message']); 
$header "From: "$name " <" $mailFrom ">\r\n";
$header .= "Content-Type: text/plain; charset=\"UTF-8\"";


$message 'Navn: '.$name.
E-post: '
.$mailFrom.
Telefon: '
.$telefon.
Adresse: '
.$adresse.
Melding: '
.$message_text;

mail($mailTo$subject$message$header);
?>
Code:
<!-- contact-form START here -->
<div id="feedback">
<p class="error wrong_name"> - Vennligst skriv inn ditt navn.</p>
<p class="error wrong_email"> - Vennligst skriv inn din e-postadresse.</p>
<p class="error wrong_message"> - Vennligst skriv inn din melding.</p>
</div>
<form action="sendemail.php" id="contact_us" method="post">
<p class="label_name">Navn</p>
<p class="input_form">
<input type="text" name="Name" />
</p>
<p class="label_name">E-post</p>
<p class="input_form">
<input type="text" name="Email" />
</p>
<p class="label_name">Telefon</p>
<p class="input_form">
<input type="text" name="Telefon" />
</p>
<p class="label_name">Adresse</p>
<p class="input_form">
<input type="text" name="Adresse" />
</p>
<p class="label_name">Emne</p>
<p class="input_form">
<input type="text" name="Subject" />
</p>
<p class="label_name">Melding</p>
<p class="input_form" id="textarea">
<textarea name="Message" rows="10" cols="4" id="message_input"></textarea>
</p>
<p class="label_name">Send yourself a copy</p>
<p class="input_form">
<input type="checkbox" name="copy" value="1" /> 
</p>
<p id="submit">
<input type="submit" value="Send" name="submitButton" class="button" />
</p>
</form>
<p id="success">Takk. Din melding ble sendt. Vi vil besvare din henvendelse så fort som mulig.</p>
<!-- contact-form END here -->
tropane is offline   Reply With Quote
Users who have thanked tropane for this post:
dylan75 (04-11-2011)
Old 04-09-2011, 12:11 PM   PM User | #9
sjaban
New to the CF scene

 
Join Date: Apr 2011
Posts: 7
Thanks: 3
Thanked 1 Time in 1 Post
sjaban is an unknown quantity at this point
Quote:
Originally Posted by tropane View Post
oh, I've mad a mistake in my code now... it should work..
PHP Code:
<?php
if(isset($_POST['copy']) && $_POST['copy'] == 1)
{
$mailTo htmlspecialchars($_POST['Email']);
$name htmlspecialchars($_POST['Name']);
$mailFrom htmlspecialchars($_POST['Email']); 
$telefon htmlspecialchars($_POST['Telefon']); 
$adresse htmlspecialchars($_POST['Adresse']); 
$subject htmlspecialchars($_POST['Subject']);
$message_text htmlspecialchars($_POST['Message']); 
$header "From: "$name " <" $mailFrom ">\r\n";
$header .= "Content-Type: text/plain; charset=\"UTF-8\"";


$message 'Navn: '.$name.
E-post: '
.$mailFrom.
Telefon: '
.$telefon.
Adresse: '
.$adresse.
Melding: '
.$message_text;

mail($mailTo$subject$message$header);
}

$mailTo 'contact@site.com';
$name htmlspecialchars($_POST['Name']);
$mailFrom htmlspecialchars($_POST['Email']); 
$telefon htmlspecialchars($_POST['Telefon']); 
$adresse htmlspecialchars($_POST['Adresse']); 
$subject htmlspecialchars($_POST['Subject']);
$message_text htmlspecialchars($_POST['Message']); 
$header "From: "$name " <" $mailFrom ">\r\n";
$header .= "Content-Type: text/plain; charset=\"UTF-8\"";


$message 'Navn: '.$name.
E-post: '
.$mailFrom.
Telefon: '
.$telefon.
Adresse: '
.$adresse.
Melding: '
.$message_text;

mail($mailTo$subject$message$header);
?>
Code:
<!-- contact-form START here -->
<div id="feedback">
<p class="error wrong_name"> - Vennligst skriv inn ditt navn.</p>
<p class="error wrong_email"> - Vennligst skriv inn din e-postadresse.</p>
<p class="error wrong_message"> - Vennligst skriv inn din melding.</p>
</div>
<form action="sendemail.php" id="contact_us" method="post">
<p class="label_name">Navn</p>
<p class="input_form">
<input type="text" name="Name" />
</p>
<p class="label_name">E-post</p>
<p class="input_form">
<input type="text" name="Email" />
</p>
<p class="label_name">Telefon</p>
<p class="input_form">
<input type="text" name="Telefon" />
</p>
<p class="label_name">Adresse</p>
<p class="input_form">
<input type="text" name="Adresse" />
</p>
<p class="label_name">Emne</p>
<p class="input_form">
<input type="text" name="Subject" />
</p>
<p class="label_name">Melding</p>
<p class="input_form" id="textarea">
<textarea name="Message" rows="10" cols="4" id="message_input"></textarea>
</p>
<p class="label_name">Send yourself a copy</p>
<p class="input_form">
<input type="checkbox" name="copy" value="1" /> 
</p>
<p id="submit">
<input type="submit" value="Send" name="submitButton" class="button" />
</p>
</form>
<p id="success">Takk. Din melding ble sendt. Vi vil besvare din henvendelse så fort som mulig.</p>
<!-- contact-form END here -->
Hi
thanks it worked, but how can fix this text in the right line?
see picture: http://bildr.no/view/860696
Her is my CSS code for contact form:

/** Contact us Form **/

#contact_us {width:460px; margin:25px 0px 0px; overflow:hidden;}

#contact_us p.label_name, #contact_us p.input_form {float:left; margin-bottom:10px;}
p.label_name {width:80px; clear:both; color:#404040; font-size:13px;}

#contact_us input, #contact_us textarea {width:370px; background:#fff; border:#515151 1px solid; font-size:12px; padding:4px; margin-bottom:15px; color:#404040; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; font-family:"Lucida Sans Unicode", "Lucida Grande", Garuda, sans-serif;}
#contact_us input.button {cursorointer; width:auto; float:right; font-size:12px;}

#feedback p {margin-bottom:5px;}
p.error {display:none; padding:5px 0px; color:#FF3300; font-size:13px; font-weight:normal;}
p#submit {text-align:right;}
p#success {display:none; font-size:14px; text-align:left; margin-bottom:20px; color:#00CC00; font-style:normal;}

Thank you so much

Last edited by sjaban; 04-09-2011 at 01:14 PM..
sjaban is offline   Reply With Quote
Old 04-09-2011, 02:36 PM   PM User | #10
tropane
New Coder

 
Join Date: Nov 2010
Location: United Kingdom
Posts: 31
Thanks: 0
Thanked 9 Times in 8 Posts
tropane is an unknown quantity at this point
Code:
<p class="label_name">&nbsp;</p>
<p class="input_form">
<input type="checkbox" name="copy" value="1" />&nbsp;<span style="text-align:right;">Send yourself a copy</span>
</p>
tropane is offline   Reply With Quote
Users who have thanked tropane for this post:
sjaban (04-09-2011)
Old 04-09-2011, 03:10 PM   PM User | #11
sjaban
New to the CF scene

 
Join Date: Apr 2011
Posts: 7
Thanks: 3
Thanked 1 Time in 1 Post
sjaban is an unknown quantity at this point
Quote:
Originally Posted by tropane View Post
Code:
<p class="label_name">&nbsp;</p>
<p class="input_form">
<input type="checkbox" name="copy" value="1" />&nbsp;<span style="text-align:right;">Send yourself a copy</span>
</p>
Thanx
But look like this now: http://bildr.no/view/860811
sjaban is offline   Reply With Quote
Old 04-09-2011, 05:11 PM   PM User | #12
tropane
New Coder

 
Join Date: Nov 2010
Location: United Kingdom
Posts: 31
Thanks: 0
Thanked 9 Times in 8 Posts
tropane is an unknown quantity at this point
Code:
<p class="label_name">&nbsp;</p>
<p class="input_form">
<input style="width:auto;" type="checkbox" name="copy" value="1" /> Send yourself a copy
</p>
tropane is offline   Reply With Quote
The Following 2 Users Say Thank You to tropane For This Useful Post:
dylan75 (04-11-2011), sjaban (04-09-2011)
Old 04-09-2011, 06:17 PM   PM User | #13
sjaban
New to the CF scene

 
Join Date: Apr 2011
Posts: 7
Thanks: 3
Thanked 1 Time in 1 Post
sjaban is an unknown quantity at this point
Thank you

Dear tropane
Thank you for all help, problem is down.
kindlig of you.

have a nice weekend
sjaban is offline   Reply With Quote
Old 04-11-2011, 05:16 PM   PM User | #14
dylan75
New to the CF scene

 
Join Date: Apr 2011
Posts: 8
Thanks: 4
Thanked 0 Times in 0 Posts
dylan75 is an unknown quantity at this point
Nice Post
dylan75 is offline   Reply With Quote
Old 10-18-2012, 08:40 AM   PM User | #15
gnoa85
New to the CF scene

 
Join Date: Oct 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
gnoa85 is an unknown quantity at this point
Quote:
Originally Posted by sjaban View Post
Hi
thanks it worked, but how can fix this text in the right line?
see picture: http://bildr.no/view/860696
Her is my CSS code for contact form:

/** Contact us Form **/

#contact_us {width:460px; margin:25px 0px 0px; overflow:hidden;}

#contact_us p.label_name, #contact_us p.input_form {float:left; margin-bottom:10px;}
p.label_name {width:80px; clear:both; color:#404040; font-size:13px;}

#contact_us input, #contact_us textarea {width:370px; background:#fff; border:#515151 1px solid; font-size:12px; padding:4px; margin-bottom:15px; color:#404040; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; font-family:"Lucida Sans Unicode", "Lucida Grande", Garuda, sans-serif;}
#contact_us input.button {cursorointer; width:auto; float:right; font-size:12px;}

#feedback p {margin-bottom:5px;}
p.error {display:none; padding:5px 0px; color:#FF3300; font-size:13px; font-weight:normal;}
p#submit {text-align:right;}
p#success {display:none; font-size:14px; text-align:left; margin-bottom:20px; color:#00CC00; font-style:normal;}

Thank you so much
Thank you
gnoa85 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:13 PM.


Advertisement
Log in to turn off these ads.