Need Help with Contact Form and Newsletter

  • manchaai
  • Born
  • Born
  • manchaai
  • Posts: 1

Post 3+ Months Ago

Hi everybody,

I bought a website template #31892, anybody can teach me to set the contact form & newsletter send the information to my email adress.

Contact Form:

HTML Code: [ Select ]
<h3>Contact Form</h3>
<form id="ContactForm" action="" enctype="multipart/form-data">
<div>
<div class="col_1">
Enter Your Name:<br />
<input type="text" class="input" />
Enter Your E-mail:<br />
<input type="text" class="input" />
Enter Your State:<br />
<input type="text" class="input" />
</div>
<div class="col_2">
Enter Your Message:<br />
<textarea cols="1" rows="1"></textarea>
</div>
<a href="#" class="link1" onclick="document.getElementById('ContactForm').submit()">Submit</a>
<a href="#" class="link1" onclick="document.getElementById('ContactForm').reset()">Clear</a>
</div>
</form>
  1. <h3>Contact Form</h3>
  2. <form id="ContactForm" action="" enctype="multipart/form-data">
  3. <div>
  4. <div class="col_1">
  5. Enter Your Name:<br />
  6. <input type="text" class="input" />
  7. Enter Your E-mail:<br />
  8. <input type="text" class="input" />
  9. Enter Your State:<br />
  10. <input type="text" class="input" />
  11. </div>
  12. <div class="col_2">
  13. Enter Your Message:<br />
  14. <textarea cols="1" rows="1"></textarea>
  15. </div>
  16. <a href="#" class="link1" onclick="document.getElementById('ContactForm').submit()">Submit</a>
  17. <a href="#" class="link1" onclick="document.getElementById('ContactForm').reset()">Clear</a>
  18. </div>
  19. </form>


Newsletter:

HTML Code: [ Select ]
<h3>Newsletter</h3>
<form id="form_1" action="" method="post">
<div>
<div class="wrapper">
<div class="bg"><input type="text" class="input"></div>
<a href="#" class="button" onClick="document.getElementById('form_1').submit()">OK</a>
</div>
<a href="#">Unsubscribe</a>
</div>
</form>
  1. <h3>Newsletter</h3>
  2. <form id="form_1" action="" method="post">
  3. <div>
  4. <div class="wrapper">
  5. <div class="bg"><input type="text" class="input"></div>
  6. <a href="#" class="button" onClick="document.getElementById('form_1').submit()">OK</a>
  7. </div>
  8. <a href="#">Unsubscribe</a>
  9. </div>
  10. </form>


Thanks for your help!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9088
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Hi Manchaai, were you ever able to get this resolved? On both of these you will see that your action attribute is blank, so for example this line:

HTML Code: [ Select ]
<form id="ContactForm" action="" enctype="multipart/form-data">


The action attribute needs to be filled into the location of a script that resides on your server to process the form, so for instance a PHP script. If you have a PHP script called contact.php you would change the line to:

HTML Code: [ Select ]
<form id="ContactForm" action="contact.php" enctype="multipart/form-data">


Here is an extremely simple example contact.php script you can use as a starting point, you will need to make sure you webhost allows you to use PHP:

PHP Code: [ Select ]
<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];
 
$mail_to = 'youremail@yourdomain.com';
$subject = 'Message from a site visitor '.$field_name;
 
$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;
 
$headers = 'From: '.$cf_email."\r\n";
$headers .= 'Reply-To: '.$cf_email."\r\n";
 
$mail_status = mail($mail_to, $subject, $body_message, $headers);
 
if ($mail_status) { ?>
   <script language="javascript" type="text/javascript">
      alert('Thank you for the message. We will contact you shortly.');
      window.location = 'contact_page.html';
   </script>
<?php
}
else { ?>
   <script language="javascript" type="text/javascript">
      alert('Message failed. Please, send an email to gordon@template-help.com');
      window.location = 'contact_page.html';
   </script>
<?php
}
?>
  1. <?php
  2. $field_name = $_POST['cf_name'];
  3. $field_email = $_POST['cf_email'];
  4. $field_message = $_POST['cf_message'];
  5.  
  6. $mail_to = 'youremail@yourdomain.com';
  7. $subject = 'Message from a site visitor '.$field_name;
  8.  
  9. $body_message = 'From: '.$field_name."\n";
  10. $body_message .= 'E-mail: '.$field_email."\n";
  11. $body_message .= 'Message: '.$field_message;
  12.  
  13. $headers = 'From: '.$cf_email."\r\n";
  14. $headers .= 'Reply-To: '.$cf_email."\r\n";
  15.  
  16. $mail_status = mail($mail_to, $subject, $body_message, $headers);
  17.  
  18. if ($mail_status) { ?>
  19.    <script language="javascript" type="text/javascript">
  20.       alert('Thank you for the message. We will contact you shortly.');
  21.       window.location = 'contact_page.html';
  22.    </script>
  23. <?php
  24. }
  25. else { ?>
  26.    <script language="javascript" type="text/javascript">
  27.       alert('Message failed. Please, send an email to gordon@template-help.com');
  28.       window.location = 'contact_page.html';
  29.    </script>
  30. <?php
  31. }
  32. ?>


This is just an example, ideally you will want to do a bit more than that and sanitize the values that are entered to make sure they are correct. You will also need to change your HTML slightly so that the script can receive the information from your form. So for instance in this example script it says this:

PHP Code: [ Select ]
$field_email = $_POST['cf_email'];


That will basically take the form element named "cf_email" which means you need to name that appropriately in you form. So your HTML would look like this for that portion:

HTML Code: [ Select ]
Enter Your E-mail:<br />
<input name="cf_email" id="cf_email" type="text" class="input" />
  1. Enter Your E-mail:<br />
  2. <input name="cf_email" id="cf_email" type="text" class="input" />


The script will be able to take the entered value then. You will need to change other form elements as well for each bit of information you want entered.

You may want to look around on the internet for a more elaborate contact script that does everything you need already, and then set your contact form to use that script by changing the action to the location of that script.

The same for your newsletter script. You will probably want to look around on the internet for some sort of newsletter PHP system that you can install on your website so that you can manage your visitors that subscribe to it. Hope this gives you a starting point if you haven't already figured this out.
  • izmoba
  • Born
  • Born
  • izmoba
  • Posts: 3

Post 3+ Months Ago

Hello i did as u said only thing is im getting empty emails here is the html css and php stuff could you just change whats wrong and explain why please thanks alot
the php contains random $field_name $_post i tryed to work with thats why theyr so messed up just please tell me what needs to be changed
Code: [ Select ]
<?php
$field_name = $_POST['Enter your Name:'];
$field_name = $_POST['Skriv inn din E-mail :'];
$field_name = $_POST['Skriv inn telefonen :'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['Skriv inn din melding:'];

$mail_to = 'notalovedtopostlinks';
$subject = 'poruka '.$field_name;

$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;

$headers = 'From: '.$cf_email."\r\n";
$headers .= 'Reply-To: '.$cf_email."\r\n";

$mail_status = mail($mail_to, $subject, $body_message, $headers);

if ($mail_status) { ?>
    <script language="javascript" type="text/javascript">
        alert('Ttest 123');
        window.location = 'index-4.html';
    </script>
<?php
}
else { ?>
    <script language="javascript" type="text/javascript">
        alert('Fail ba');
        window.location = 'index-4.html';
    </script>
<?php
}
?>
  1. <?php
  2. $field_name = $_POST['Enter your Name:'];
  3. $field_name = $_POST['Skriv inn din E-mail :'];
  4. $field_name = $_POST['Skriv inn telefonen :'];
  5. $field_email = $_POST['cf_email'];
  6. $field_message = $_POST['Skriv inn din melding:'];
  7. $mail_to = 'notalovedtopostlinks';
  8. $subject = 'poruka '.$field_name;
  9. $body_message = 'From: '.$field_name."\n";
  10. $body_message .= 'E-mail: '.$field_email."\n";
  11. $body_message .= 'Message: '.$field_message;
  12. $headers = 'From: '.$cf_email."\r\n";
  13. $headers .= 'Reply-To: '.$cf_email."\r\n";
  14. $mail_status = mail($mail_to, $subject, $body_message, $headers);
  15. if ($mail_status) { ?>
  16.     <script language="javascript" type="text/javascript">
  17.         alert('Ttest 123');
  18.         window.location = 'index-4.html';
  19.     </script>
  20. <?php
  21. }
  22. else { ?>
  23.     <script language="javascript" type="text/javascript">
  24.         alert('Fail ba');
  25.         window.location = 'index-4.html';
  26.     </script>
  27. <?php
  28. }
  29. ?>


here is the html

Code: [ Select ]
<h2 class="marg_top1">Send e-mail</h2>
                        <form id="ContactForm" action="contact.php" enctype="multipart/form-data">
                     <div>
                            <div class="rows"><input class="input" type="text" value="Skriv inn navnet ditt :" onblur="if(this.value=='') this.value='Enter your Name:'" onFocus="if(this.value =='Enter your Name:' ) this.value=''"  /></div>
                            <div class="rows"><input class="input" type="text" value="Skriv inn din E-mail :" onblur="if(this.value=='') this.value='Enter your E-mail:'" onFocus="if(this.value =='Enter your E-mail:' ) this.value=''"  /></div>
                            <div class="rows"><input class="input" type="text" value="Skriv inn telefonen :" onblur="if(this.value=='') this.value='Enter your Phone:'" onFocus="if(this.value =='Enter your Phone:' ) this.value=''"  /></div>
                            <div class="textarea_box"><textarea cols="1" rows="1" onBlur="if(this.value=='') this.value='Enter your Message:'" onFocus="if(this.value =='Enter your Message:' ) this.value=''" >Skriv inn din melding:</textarea></div>
                            <a href="#" class="link1" onClick="document.getElementById('ContactForm').reset()">Avbryt</a>
                            <a href="#" class="link1" onClick="document.getElementById('ContactForm').submit()">Send</a>
                        </div>
                        </form>
                    </div>
                </div>
  1. <h2 class="marg_top1">Send e-mail</h2>
  2.                         <form id="ContactForm" action="contact.php" enctype="multipart/form-data">
  3.                      <div>
  4.                             <div class="rows"><input class="input" type="text" value="Skriv inn navnet ditt :" onblur="if(this.value=='') this.value='Enter your Name:'" onFocus="if(this.value =='Enter your Name:' ) this.value=''"  /></div>
  5.                             <div class="rows"><input class="input" type="text" value="Skriv inn din E-mail :" onblur="if(this.value=='') this.value='Enter your E-mail:'" onFocus="if(this.value =='Enter your E-mail:' ) this.value=''"  /></div>
  6.                             <div class="rows"><input class="input" type="text" value="Skriv inn telefonen :" onblur="if(this.value=='') this.value='Enter your Phone:'" onFocus="if(this.value =='Enter your Phone:' ) this.value=''"  /></div>
  7.                             <div class="textarea_box"><textarea cols="1" rows="1" onBlur="if(this.value=='') this.value='Enter your Message:'" onFocus="if(this.value =='Enter your Message:' ) this.value=''" >Skriv inn din melding:</textarea></div>
  8.                             <a href="#" class="link1" onClick="document.getElementById('ContactForm').reset()">Avbryt</a>
  9.                             <a href="#" class="link1" onClick="document.getElementById('ContactForm').submit()">Send</a>
  10.                         </div>
  11.                         </form>
  12.                     </div>
  13.                 </div>


here is the css style

Code: [ Select ]
#ContactForm { padding-top:5px;}
#ContactForm .rows{ min-height:49px;}
#ContactForm .textarea_box{ min-height:240px; border-bottom:1px solid #9a9999; margin-bottom:8px;}
#ContactForm a{ margin-right:30px}
#ContactForm .input {width:355px; height:16px; border:1px solid #525251; background: url(../../../slibe/wt_32632/images/bg_form.png) repeat; padding:8px; color:#aaaaaa; font:13px "Trebuchet MS", Arial, Helvetica, sans-serif}
#ContactForm textarea { overflow: auto;width:355px; height:206px; border:1px solid #525251; background: url(../../../slibe/wt_32632/images/bg_form.png) repeat; padding:8px; color:#aaaaaa; font:13px "Trebuchet MS", Arial, Helvetica, sans-serif}
  1. #ContactForm { padding-top:5px;}
  2. #ContactForm .rows{ min-height:49px;}
  3. #ContactForm .textarea_box{ min-height:240px; border-bottom:1px solid #9a9999; margin-bottom:8px;}
  4. #ContactForm a{ margin-right:30px}
  5. #ContactForm .input {width:355px; height:16px; border:1px solid #525251; background: url(../../../slibe/wt_32632/images/bg_form.png) repeat; padding:8px; color:#aaaaaa; font:13px "Trebuchet MS", Arial, Helvetica, sans-serif}
  6. #ContactForm textarea { overflow: auto;width:355px; height:206px; border:1px solid #525251; background: url(../../../slibe/wt_32632/images/bg_form.png) repeat; padding:8px; color:#aaaaaa; font:13px "Trebuchet MS", Arial, Helvetica, sans-serif}
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9088
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

The main issue I am seeing for you are the variables:

PHP Code: [ Select ]
$field_name = $_POST['Enter your Name:'];
$field_name = $_POST['Skriv inn din E-mail :'];
$field_name = $_POST['Skriv inn telefonen :'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['Skriv inn din melding:'];
  1. $field_name = $_POST['Enter your Name:'];
  2. $field_name = $_POST['Skriv inn din E-mail :'];
  3. $field_name = $_POST['Skriv inn telefonen :'];
  4. $field_email = $_POST['cf_email'];
  5. $field_message = $_POST['Skriv inn din melding:'];


These need to be variables that are being used in your HTML form. So for example I would change it to something like:

PHP Code: [ Select ]
$field_name = $_POST['full_name'];
$field_email = $_POST['email'];
$field_telephone = $_POST['telephone'];
$field_message = $_POST['message'];
  1. $field_name = $_POST['full_name'];
  2. $field_email = $_POST['email'];
  3. $field_telephone = $_POST['telephone'];
  4. $field_message = $_POST['message'];


See the part I changed? So full_name, email, telephone, and message that are referenced inside that $_POST array are the variables inside your HTML, you will need to make sure that your HTML matches appropriately so that your script can use the data. So for instance in your HTML lets take part of it:

HTML Code: [ Select ]
<div class="rows"><input class="input" type="text" value="Skriv inn navnet ditt :" onblur="if(this.value=='') this.value='Enter your Name:'" onFocus="if(this.value =='Enter your Name:' ) this.value=''"  /></div>


See the problem there is that you have not named your input so there is no way that your contact.php form knows what information is being passed. You need to add a name attribute so that the PHP script can reference it, and it must match what your PHP script is looking for. So remember for the name above we used:

PHP Code: [ Select ]
$field_name = $_POST['full_name'];


So it is looking for the input field with the name of full_name. So lets modify your HTML to have that now:

HTML Code: [ Select ]
<div class="rows"><input name="full_name" class="input" type="text" value="Skriv inn navnet ditt :" onblur="if(this.value=='') this.value='Enter your Name:'" onFocus="if(this.value =='Enter your Name:' ) this.value=''"  /></div>


See the addition of: name="full_name"

Now your script will be able to use whatever value that you put in that input box. You will need to make similar changes to the rest of your HTML. Remember, all of these parts we have changed are what goes on behind the scenes, your users do not see these names on the actual website (unless they view your source).
  • izmoba
  • Born
  • Born
  • izmoba
  • Posts: 3

Post 3+ Months Ago

I did as you said WORKS charming mails getting delivered only problem now is when i use that
Code: [ Select ]
<input name="message"
in
Code: [ Select ]
<div class="textarea_box"><textarea cols="1" rows="1" onBlur="if(this.value=='') this.value='Enter your Message:'" onFocus="if(this.value =='Enter your Message:' ) this.value=''" >Skriv inn din melding:</textarea></div>

it adds a nasty ugly white little box where u can type text in it and it doest look good with the template neither it can be edited
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9088
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

You won't need to use an input in there, as the textarea itself is what you need to have a name attribute on. So simply do something like:

HTML Code: [ Select ]
<div class="textarea_box"><textarea name="message" cols="1" rows="1" onBlur="if(this.value=='') this.value='Enter your Message:'" onFocus="if(this.value =='Enter your Message:' ) this.value=''" >Skriv inn din melding:</textarea></div>
  • izmoba
  • Born
  • Born
  • izmoba
  • Posts: 3

Post 3+ Months Ago

exactly done like that works great thanks alot you know your trade :)

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 49 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.