Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 23
Like Tree1Likes

Thread: Creating a newsletter form

  1. #11
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,974
    Member #
    5580
    Liked
    760 times
    You will need to use an html email instead of plain text. Im not on a pc right now ... using a kindle. Ill give an example script tomorrow or friday because tomorrow is u.s. independence day. Ill be out partying. Ill post an example script for you to try.


  2.  

  3. #12
    Member Elvedin's Avatar
    Join Date
    Jan 2013
    Location
    Bosnia And Herzegowina
    Posts
    78
    Member #
    35009
    mlseim , then happy independence day if you celebrate it

    However , i found out how to make it myself and i am really happy now.

    Is this okay :

    HTML Code:
    <form id="newsletter" action="mail/newsletter.php" method="post">                  <div class="wrapper">                    <div class="bg">                      <input type="hidden" name="name" value="e-Novosti" onBlur="if(this.value=='') this.value='e-Novosti'" onFocus="if(this.value =='e-Novosti' ) this.value=''" />                      <input type="hidden" name="message" value="" onBlur="if(this.value=='') this.value=''" onFocus="if(this.value =='' ) this.value=''" />                      <input type="text" name="email" value="Unesite vašu e-mail adresu" onBlur="if(this.value=='') this.value='Unesite vašu e-mail adresu'" onFocus="if(this.value =='Unesite vašu e-mail adresu' ) this.value=''" />                    </div>                  </div>                 <a class="button" onClick="document.getElementById('newsletter').submit()"><span><span><strong>Pretplati se</strong></span></span></a>                </form>
    PHP Code:
    <?php header("Refresh: 5;url=http://slarkdesign.com"); 
    $to "info@slarkdesign.com";$name=$_POST['name'];$email $_POST ['email'];$message $_POST['message'];$headers "From:" $email  ;mail($to,$name,$message,$headers);

    if(
    mail){ echo "<html>"; echo "<head>"; echo "<title>Slark Design - e-Novosti</title>"; echo '<style type="text/css">';include '../css/newsletter.css';echo '</style>';echo "</head>"; echo "<body>"; echo "<div class='newsletter-success'></div>"; echo "</body>"; echo "</html>"; }else{     echo "<html>"; echo "<head>"; echo "<title>Slark Design - e-Novosti</title>"; echo '<style type="text/css">';include '../css/newsletter.css';echo '</style>';echo "</head>"; echo "<body>"; echo "<div class='newsletter-failed'></div>"; echo "</body>"; echo "</html>"; } ?>
    It works exactly like i wanted. Did i make it good ?

    Thank you for supporting

  4. #13
    Member Elvedin's Avatar
    Join Date
    Jan 2013
    Location
    Bosnia And Herzegowina
    Posts
    78
    Member #
    35009
    Hmm and i got an new idea , to make it easier. is it possible to edit this php codes that i wrote this post before, everyone who type in his e mail in newsletter field and press the button subscribe , his e mail to be written in one text document.
    So every time some1 type in his mail and press submit his email should be written in new line,
    I think its an good idea, can you help me to code that out ? Ofc after holidays finish.

  5. #14
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,974
    Member #
    5580
    Liked
    760 times
    Doing that (using a plain text file as a database), would be a good idea.


  6. #15
    Member Elvedin's Avatar
    Join Date
    Jan 2013
    Location
    Bosnia And Herzegowina
    Posts
    78
    Member #
    35009
    yep, so when you will be able to help me to work on it tell me )

  7. #16
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,974
    Member #
    5580
    Liked
    760 times
    Super easy to append to a text file.
    You can add the portion to append emails to a file and simply comment-out the if(mail()) line in your script.

    Instead of just posting a script, look at this tutorial. You'll not only see an example, but learn more by seeing the tutorials. And while you're at it, look at some of the other tutorials on that website. It's a really great place to learn PHP.

    Here's the append tutorial:
    PHP Tutorial - File Append


  8. #17
    Member Elvedin's Avatar
    Join Date
    Jan 2013
    Location
    Bosnia And Herzegowina
    Posts
    78
    Member #
    35009
    hmmm i dont know where directly to add it , and this code should look like that :

    PHP Code:
    $myFile "testFile.txt";
    $fh fopen($myFile'a'); 
    I should only repleace this
    Code:
    "testFile.txt"
    with name of my own code , something like this
    Code:
    "newsletter.txt"
    So :

    PHP Code:
    if(mail){ 
    now i dont know the next step hmm

  9. #18
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,974
    Member #
    5580
    Liked
    760 times
    Code:
    <?php 
    header("Refresh: 5;url=http://slarkdesign.com"); 
    $to = "info@slarkdesign.com";
    $name=$_POST['name'];
    $email = $_POST ['email'];
    $message = $_POST['message'];
    $headers = "From:" . $email  ;
    
    // mail($to,$name,$message,$headers);
    
    $myFile = "newsletter.txt";
    $fh = fopen($myFile, '+a');
    
    $stringData = $email."|".$name."|".$message\n"; 
    fwrite($fh, $stringData); 
    fclose($fh);
    
    // if(mail){ 
    
    echo "<html>"; 
    echo "<head>"; 
    echo "<title>Slark Design - e-Novosti</title>"; 
    echo '<style type="text/css">';
    include '../css/newsletter.css';
    echo '</style>';
    echo "</head>"; 
    echo "<body>"; 
    echo "<div class='newsletter-success'></div>"; 
    echo "</body>"; 
    echo "</html>"; 
    
    // }
    // else{     
    // echo "<html>"; 
    // echo "<head>"; 
    // echo "<title>Slark Design - e-Novosti</title>"; 
    // echo '<style type="text/css">';
    // include '../css/newsletter.css';
    // echo '</style>';
    // echo "</head>"; 
    // echo "<body>"; 
    // echo "<div class='newsletter-failed'></div>"; 
    // echo "</body>"; 
    // echo "</html>"; 
    // } 
    
    ?>
    Last edited by mlseim; Jul 05th, 2013 at 12:40 PM.


  10. #19
    Member Elvedin's Avatar
    Join Date
    Jan 2013
    Location
    Bosnia And Herzegowina
    Posts
    78
    Member #
    35009
    Thank you Mlseim , but something goes wrong

    I got an new page opened after click submit with this text :

    Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/slarkdes/public_html/mail/newsletter.php on line 14

    Parse error: syntax error, unexpected T_STRING in /home/slarkdes/public_html/mail/newsletter.php on line 14
    And the line 14 is that here :

    PHP Code:
    $stringData $email."|".$name."|".$message\n"; 
    Hmm, what could be wrong ?

  11. #20
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,974
    Member #
    5580
    Liked
    760 times
    $stringData = $email."|".$name."|".$message."\n";



    I made a typo. And this text editor sucks ...
    I can't stand this new forum software ... it's almost totally unusable.



Page 2 of 3 FirstFirst 1 2 3 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:35 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com