need a simple php code created

 

Results 1 to 29 of 29
So I have a small generator that adds content to a config.php file but I ...
  1. #1
    webdy's Avatar
    webdy is offline Newbies
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    8
    Thanked 20 Times in 10 Posts

    Default need a simple php code created

    So I have a small generator that adds content to a config.php file but I also want to to send an email to the recipient.
    Can you please help me.
    Here is the generator code:
    PHP Code:
    <?php
    if (isset($_POST["Submit"])) {
    $string '<?php $date1 = "'$_POST["date1"]. '";$email2 = "'$_POST["email2"]. '";$email1 = "'$_POST["email1"]. '";?>';
    $fp fopen("config.php""w");fwrite($fp$string);fclose($fp);
    }
    ?><style type="text/css"><!--.style1 {color: #000000}--></style>
    <form action="" method="post" name="install" id="install">
    And here si the config:
    PHP Code:
    <?php $date1 "";$email2 "";$email1 "";?>
    I need a command code when the generator.php is submitted it will also send a email.html with the $date1 details and so on.
    Can anyone help? rep and thanks given even a quick $




  2. #2
    innozemec's Avatar
    innozemec is offline ★★ InstantLinkIndexer.com
    Join Date
    Aug 2011
    Location
    www.Indexification.com
    Posts
    4,887
    Thanks
    1,311
    Thanked 1,627 Times in 1,283 Posts
    Blog Entries
    4

    Default Re: need a simple php code created

    Code:
    <?php
    if (isset($_POST["Submit"])) {
    $string = '<?php $date1 = "'. $_POST["date1"]. '";$email2 = "'. $_POST["email2"]. '";$email1 = "'. $_POST["email1"]. '";?>';
    $fp = fopen("config.php", "w");fwrite($fp, $string);fclose($fp);
    
    $emailbody=$date1;
    mail($email1,'Subject Here',$emailbody);
    }
    ?><style type="text/css"><!--.style1 {color: #000000}--></style>
    <form action="" method="post" name="install" id="install">
    Simply put whatever you need in $emailbody... also change $email1 with the proper variable holding the recipient address, and change your subject..

    let me know if you need any more help..

    also you can refer to: http://www.php.net/manual/en/function.mail.php

  3. #3
    webdy's Avatar
    webdy is offline Newbies
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    8
    Thanked 20 Times in 10 Posts

    Default Re: need a simple php code created

    Quote Originally Posted by innozemec View Post
    Code:
    <?php
    if (isset($_POST["Submit"])) {
    $string = '<?php $date1 = "'. $_POST["date1"]. '";$email2 = "'. $_POST["email2"]. '";$email1 = "'. $_POST["email1"]. '";?>';
    $fp = fopen("config.php", "w");fwrite($fp, $string);fclose($fp);
    
    $emailbody=$date1;
    mail($email1,'Subject Here',$emailbody);
    }
    ?><style type="text/css"><!--.style1 {color: #000000}--></style>
    <form action="" method="post" name="install" id="install">
    Simply put whatever you need in $emailbody... also change $email1 with the proper variable holding the recipient address, and change your subject..

    let me know if you need any more help..

    also you can refer to: http://www.php.net/manual/en/function.mail.php
    Hi innozemec and thanks for your reply.
    I`m a noob in php so for me is just copy and paste.
    I`m planning to send as a confirmation when the form is submitted a newsletter like this picture here:
    http://1.1.1.1/bmi/0.s3.envato.com/f...4_preview4.jpg
    It will be a full html and the generator will replace some values in the newsletter with the content of the form submitted and send it to the $date1.

    Can you please show me an example of code that I can use to develop in a full working script.

  4. #4
    innozemec's Avatar
    innozemec is offline ★★ InstantLinkIndexer.com
    Join Date
    Aug 2011
    Location
    www.Indexification.com
    Posts
    4,887
    Thanks
    1,311
    Thanked 1,627 Times in 1,283 Posts
    Blog Entries
    4

    Default Re: need a simple php code created

    your image doesn't load.. anyways here's a sample code...

    Code:
    $emailbody=file_get_contents('PATH_TO_HTML_FILE_HERE');
    
    $emailbody=str_replace('VARIABLE',$date1,$emailbody);
    $emailbody=str_replace('VARIABLE2',$email2,$emailbody);
    
    mail($mail1,'subject here',$emailbody);
    simply do the necessary changes of the code and add as many str_replaces as you need before mailing..

  5. #5
    webdy's Avatar
    webdy is offline Newbies
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    8
    Thanked 20 Times in 10 Posts

    Default Re: need a simple php code created

    Quote Originally Posted by innozemec View Post
    your image doesn't load.. anyways here's a sample code...

    Code:
    $emailbody=file_get_contents('PATH_TO_HTML_FILE_HERE');
    
    $emailbody=str_replace('VARIABLE',$date1,$emailbody);
    $emailbody=str_replace('VARIABLE2',$email2,$emailbody);
    
    mail($mail1,'subject here',$emailbody);
    simply do the necessary changes of the code and add as many str_replaces as you need before mailing..
    Thank you very much.

  6. #6
    innozemec's Avatar
    innozemec is offline ★★ InstantLinkIndexer.com
    Join Date
    Aug 2011
    Location
    www.Indexification.com
    Posts
    4,887
    Thanks
    1,311
    Thanked 1,627 Times in 1,283 Posts
    Blog Entries
    4

    Default Re: need a simple php code created

    Quote Originally Posted by webdy View Post
    Thank you very much.
    no probs, keep me posted if you need any more help

  7. #7
    webdy's Avatar
    webdy is offline Newbies
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    8
    Thanked 20 Times in 10 Posts

    Default Re: need a simple php code created

    Quote Originally Posted by innozemec View Post
    no probs, keep me posted if you need any more help

    PHP Code:
    $method "'. $_POST["method"]. '";?>';
    $fp = fopen("config.php", "w");fwrite($fp, $string);fclose($fp);
    $emailbody=file_get_contents('newsletter.html');
    $emailbody=str_replace('VARIABLE',$var1,$emailbody);$emailbody=str_replace('VARIABLE2',$var2,$emailbody);$emailbody=str_replace('VARIABLE3',$va3,$emailbody);$emailbody=str_replace('VARIABLE4',$var4,$emailbody);
    mail($email3,'You registration was a success',$emailbody);}
    ?> 
    But it does not send
    Can you please tell me what am I doing wrong?
    using phpdesigner 8 it shows a red line where $emailbody=file_get_contents('newsletter.html'); is .
    Any suggestions?

  8. #8
    metra's Avatar
    metra is offline Junior Member
    Join Date
    Jun 2012
    Location
    -. ..- .-.. .-..
    Posts
    156
    Thanks
    85
    Thanked 47 Times in 28 Posts

    Default Re: need a simple php code created

    Quote Originally Posted by webdy View Post
    PHP Code:
    $method "'. $_POST["method"]. '";?>';
    $fp = fopen("config.php", "w");fwrite($fp, $string);fclose($fp);
    $emailbody=file_get_contents('newsletter.html');
    $emailbody=str_replace('VARIABLE',$var1,$emailbody);$emailbody=str_replace('VARIABLE2',$var2,$emailbody);$emailbody=str_replace('VARIABLE3',$va3,$emailbody);$emailbody=str_replace('VARIABLE4',$var4,$emailbody);
    mail($email3,'You registration was a success',$emailbody);}
    ?> 
    But it does not send
    Can you please tell me what am I doing wrong?
    using phpdesigner 8 it shows a red line where $emailbody=file_get_contents('newsletter.html'); is .
    Any suggestions?
    There were a few syntax errors in the code:
    PHP Code:
    $method $_POST["method"];
    $fp fopen("config.php""w");fwrite($fp$string);fclose($fp);
    $emailbody=file_get_contents('newsletter.html');$emailbody=str_replace('VARIABLE',$var1,$emailbody);$emailbody=str_replace('VARIABLE2',$var2,$emailbody);$emailbody=str_replace('VARIABLE3',$va3,$emailbody);$emailbody=str_replace('VARIABLE4',$var4,$emailbody);
    mail($email3,'You registration was a success',$emailbody); 
    Try to see if that works. I haven't tested this so not sure - assuming your initial code was correct, the above version is the exact same with syntax errors fixed

    Best,
    - Metra

  9. #9
    innozemec's Avatar
    innozemec is offline ★★ InstantLinkIndexer.com
    Join Date
    Aug 2011
    Location
    www.Indexification.com
    Posts
    4,887
    Thanks
    1,311
    Thanked 1,627 Times in 1,283 Posts
    Blog Entries
    4

    Default Re: need a simple php code created

    there's an error at the end.. from where that extra } comes in..

  10. #10
    webdy's Avatar
    webdy is offline Newbies
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    8
    Thanked 20 Times in 10 Posts

    Default Re: need a simple php code created

    Quote Originally Posted by innozemec View Post
    there's an error at the end.. from where that extra } comes in..

    PHP Code:
    <?php
    if (isset($_POST["Submit"])) {
    $string '<?php $var = "'$_POST["var"]. '";$var2 = "'$_POST["var2"]. '";$var3 = "'$_POST["var3"]. '";$var4 = "'$_POST["var4"]. '";$method = $_POST["method"];?>';
    $fp fopen("config.php""w");fwrite($fp$string);fclose($fp);$emailbody=file_get_contents('newsletter.html');$emailbody=str_replace('VARIABLE',$var,$emailbody);$emailbody=str_replace('VARIABLE2',$var2,$emailbody);$emailbody=str_replace('VARIABLE3',$var3,$emailbody);$emailbody=str_replace('VARIABLE4',$var4,$emailbody);
    mail($email3,'You registration was a success',$emailbody); }
    ?>
    Thats all the code tried it a lot of times and no success.

  11. #11
    innozemec's Avatar
    innozemec is offline ★★ InstantLinkIndexer.com
    Join Date
    Aug 2011
    Location
    www.Indexification.com
    Posts
    4,887
    Thanks
    1,311
    Thanked 1,627 Times in 1,283 Posts
    Blog Entries
    4

    Default Re: need a simple php code created

    Quote Originally Posted by webdy View Post
    PHP Code:
    <?php
    if (isset($_POST["Submit"])) {
    $string '<?php $var = "'$_POST["var"]. '";$var2 = "'$_POST["var2"]. '";$var3 = "'$_POST["var3"]. '";$var4 = "'$_POST["var4"]. '";$method = $_POST["method"];?>';
    $fp fopen("config.php""w");fwrite($fp$string);fclose($fp);$emailbody=file_get_contents('newsletter.html');$emailbody=str_replace('VARIABLE',$var,$emailbody);$emailbody=str_replace('VARIABLE2',$var2,$emailbody);$emailbody=str_replace('VARIABLE3',$var3,$emailbody);$emailbody=str_replace('VARIABLE4',$var4,$emailbody);
    mail($email3,'You registration was a success',$emailbody); }
    ?>
    Thats all the code tried it a lot of times and no success.
    ok, what exactly is not working?
    Is it writing the config at all?
    Is the $email3 variable holding the recipient's email?
    Where are you testing the script? If on your local windows machine, then no email will be sent as local mail server is not configured by default..

  12. #12
    webdy's Avatar
    webdy is offline Newbies
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    8
    Thanked 20 Times in 10 Posts

    Default Re: need a simple php code created

    I`m testing it directly on hostgator vps.
    Config file holds the recipients email it just does not send the email.html to $email3

  13. #13
    innozemec's Avatar
    innozemec is offline ★★ InstantLinkIndexer.com
    Join Date
    Aug 2011
    Location
    www.Indexification.com
    Posts
    4,887
    Thanks
    1,311
    Thanked 1,627 Times in 1,283 Posts
    Blog Entries
    4

    Default Re: need a simple php code created

    well, i see in the config you write variables like $_POST["var"]..., while in the mail() you put $email3
    are you sure there is something in $email3 variable? echo its content to make sure there is content in it..

    the same for str_replace()... in your config you use $_POST[..], while in the str_replace() you use direct variables.. if your register_globals is turned off, then all those variables will be empty..

  14. The Following User Says Thank You to innozemec For This Useful Post:

    webdy (02-11-2013)

  15. #14
    webdy's Avatar
    webdy is offline Newbies
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    8
    Thanked 20 Times in 10 Posts

    Default Re: need a simple php code created

    register_globals is on
    $var3= $email3
    I replaced it. I don`t really get it why is not working.
    Can you test it on your server? Can you do that?

  16. #15
    innozemec's Avatar
    innozemec is offline ★★ InstantLinkIndexer.com
    Join Date
    Aug 2011
    Location
    www.Indexification.com
    Posts
    4,887
    Thanks
    1,311
    Thanked 1,627 Times in 1,283 Posts
    Blog Entries
    4

    Default Re: need a simple php code created

    there's no need to test it on my server as i am sure it should work.. i have done this thousands of times..

    there might be some server issue.. try this

    make a tmp.php file with just this content:

    Code:
    <?php
    error_reporting(E_ALL);
    mail('PUT_YOUR_EMAIL_HERE','Hello','Hello');
    ?>
    upload the tmp.php to your server and visit its url in your browser.. see for any errors and check your email if you received an email..

  17. #16
    webdy's Avatar
    webdy is offline Newbies
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    8
    Thanked 20 Times in 10 Posts

    Default Re: need a simple php code created

    Quote Originally Posted by innozemec View Post
    there's no need to test it on my server as i am sure it should work.. i have done this thousands of times..

    there might be some server issue.. try this

    make a tmp.php file with just this content:

    Code:
    <?php
    error_reporting(E_ALL);
    mail('PUT_YOUR_EMAIL_HERE','Hello','Hello');
    ?>
    upload the tmp.php to your server and visit its url in your browser.. see for any errors and check your email if you received an email..
    I`m getting an empty email with
    "hello".

  18. #17
    innozemec's Avatar
    innozemec is offline ★★ InstantLinkIndexer.com
    Join Date
    Aug 2011
    Location
    www.Indexification.com
    Posts
    4,887
    Thanks
    1,311
    Thanked 1,627 Times in 1,283 Posts
    Blog Entries
    4

    Default Re: need a simple php code created

    ok, then mailing is good, there is some issue in your code..

    now paste me the exact full code you use and make it one statement a line, as it is hard to be read here with multiple statements a line..

  19. #18
    webdy's Avatar
    webdy is offline Newbies
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    8
    Thanked 20 Times in 10 Posts

    Default Re: need a simple php code created

    This is the form:
    PHP Code:
    <?php
    if (isset($_POST["Submit"])) {
    $string '<?php $name = "'$_POST["name"]. '";$title = "'$_POST["title"]. '";$email3 = "'$_POST["email3"]. '";$description = "'$_POST["description"]. '";?>';
    $fp fopen("config.php""w");fwrite($fp$string);fclose($fp);
    $emailbody=file_get_contents('newsletter.html');
    $emailbody=str_replace('VARIABLE',$name,$emailbody);$emailbody=str_replace('VARIABLE2',$title,$emailbody);$emailbody=str_replace('VARIABLE3',$email3,$emailbody);$emailbody=str_replace('VARIABLE4',$description,$emailbody);
    mail($email3,'Your registration was confirmed ',$emailbody);}
    ?>
    And this is the config:

    PHP Code:
    <?php $name "";$title "";$descption "";$email3 "";?>

  20. #19
    webdy's Avatar
    webdy is offline Newbies
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    8
    Thanked 20 Times in 10 Posts

    Default Re: need a simple php code created

    i tried to put one statement a line but it doesn`t show like that,

  21. #20
    innozemec's Avatar
    innozemec is offline ★★ InstantLinkIndexer.com
    Join Date
    Aug 2011
    Location
    www.Indexification.com
    Posts
    4,887
    Thanks
    1,311
    Thanked 1,627 Times in 1,283 Posts
    Blog Entries
    4

    Default Re: need a simple php code created

    change to this code and execute:

    Code:
     <?php
    error_reporting(E_ALL);
    if (isset($_POST["Submit"])) {
    $string = '<?php $name = "'. $_POST["name"]. '";$title = "'. $_POST["title"]. '";$email3 = "'. $_POST["email3"]. '";$description = "'. $_POST["description"]. '";?>';
    $fp = fopen("config.php", "w");fwrite($fp, $string);fclose($fp);
    $emailbody=file_get_contents('newsletter.html');
    $emailbody=str_replace('VARIABLE',$name,$emailbody);$emailbody=str_replace('VARIABLE2',$title,$emailbody);$emailbody=str_replace('VARIABLE3',$email3,$emailbody);$emailbody=str_replace('VARIABLE4',$description,$emailbody);
    echo $_POST["email3"];
    mail($_POST["email3"],'Your registration was confirmed ',$emailbody);}
    ?>
    see if your get any email printed out and email sent to the recipient email..

  22. The Following User Says Thank You to innozemec For This Useful Post:

    webdy (02-11-2013)

  23. #21
    webdy's Avatar
    webdy is offline Newbies
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    8
    Thanked 20 Times in 10 Posts

    Default Re: need a simple php code created

    Quote Originally Posted by innozemec View Post
    change to this code and execute:

    Code:
     <?php
    error_reporting(E_ALL);
    if (isset($_POST["Submit"])) {
    $string = '<?php $name = "'. $_POST["name"]. '";$title = "'. $_POST["title"]. '";$email3 = "'. $_POST["email3"]. '";$description = "'. $_POST["description"]. '";?>';
    $fp = fopen("config.php", "w");fwrite($fp, $string);fclose($fp);
    $emailbody=file_get_contents('newsletter.html');
    $emailbody=str_replace('VARIABLE',$name,$emailbody);$emailbody=str_replace('VARIABLE2',$title,$emailbody);$emailbody=str_replace('VARIABLE3',$email3,$emailbody);$emailbody=str_replace('VARIABLE4',$description,$emailbody);
    echo $_POST["email3"];
    mail($_POST["email3"],'Your registration was confirmed ',$emailbody);}
    ?>
    see if your get any email printed out and email sent to the recipient email..
    Thanks for your time.
    It sends the email now but it sends it like in html code
    HTML Code:
    <html>
            <head>
                    <title></title>
            </head>
            <body>
                    <p>
                            &nbsp;</p>
                    <table style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" width="600">
                            <tbody>
                                    <tr>
                                            <td style="margin: 0px;">
                                                    <div style="font-family: Verdana; font-size: 10px; color: rgb(51, 51, 51); text-align: right;">

  24. #22
    innozemec's Avatar
    innozemec is offline ★★ InstantLinkIndexer.com
    Join Date
    Aug 2011
    Location
    www.Indexification.com
    Posts
    4,887
    Thanks
    1,311
    Thanked 1,627 Times in 1,283 Posts
    Blog Entries
    4

    Default Re: need a simple php code created

    ok, great!

    add this before the mail() statement

    Code:
    $header='MIME-Version: 1.0' . "\r\n";
    $header.='Content-type: text/html; charset=utf-8' . "\r\n";
    and change the mail statement to:

    Code:
    mail($_POST["email3"],'Your registration was confirmed ',$emailbody, $header);

  25. #23
    webdy's Avatar
    webdy is offline Newbies
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    8
    Thanked 20 Times in 10 Posts

    Default Re: need a simple php code created

    Thank you very much. I can`t give you more rep but that you for your time.

  26. #24
    innozemec's Avatar
    innozemec is offline ★★ InstantLinkIndexer.com
    Join Date
    Aug 2011
    Location
    www.Indexification.com
    Posts
    4,887
    Thanks
    1,311
    Thanked 1,627 Times in 1,283 Posts
    Blog Entries
    4

    Default Re: need a simple php code created

    Quote Originally Posted by webdy View Post
    Thank you very much. I can`t give you more rep but that you for your time.
    thats no problems, enjoy

  27. #25
    webdy's Avatar
    webdy is offline Newbies
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    8
    Thanked 20 Times in 10 Posts

    Default Re: need a simple php code created

    one more quick question.
    The email is still being sent as html code and what should I write in the newsletter.html were the values should be replaced.
    is $email3 enough?

  28. #26
    innozemec's Avatar
    innozemec is offline ★★ InstantLinkIndexer.com
    Join Date
    Aug 2011
    Location
    www.Indexification.com
    Posts
    4,887
    Thanks
    1,311
    Thanked 1,627 Times in 1,283 Posts
    Blog Entries
    4

    Default Re: need a simple php code created

    when your content is html it will send it as html, if you type plain text, it will send it as plain text..

    in your newsletter.html you can't put directly php variables, but you need to put like VARIABLE1, VARIABLE2... that get replaced with the str_replace statements in the script code..

  29. #27
    webdy's Avatar
    webdy is offline Newbies
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    8
    Thanked 20 Times in 10 Posts

    Default Re: need a simple php code created

    Quote Originally Posted by webdy View Post
    one more quick question.
    The email is still being sent as html code and what should I write in the newsletter.html were the values should be replaced.
    is $email3 enough?
    made it sent html it was just a missing "."
    But the values in newsletter.html are not replaced.
    I gived newsletter 777 permissions but still not replacing

  30. #28
    webdy's Avatar
    webdy is offline Newbies
    Join Date
    Jan 2012
    Posts
    67
    Thanks
    8
    Thanked 20 Times in 10 Posts

    Default Re: need a simple php code created

    To worth millions.. Thank you for your time again. That solved it.

  31. #29
    innozemec's Avatar
    innozemec is offline ★★ InstantLinkIndexer.com
    Join Date
    Aug 2011
    Location
    www.Indexification.com
    Posts
    4,887
    Thanks
    1,311
    Thanked 1,627 Times in 1,283 Posts
    Blog Entries
    4

    Default Re: need a simple php code created

    in your newsletter.html put for example VARIABLE where you want something to be displayed.

    then in your script code do like

    $emailbody=str_replace('VARIABLE',$_POST['PHP_VARIABLE_HERE'],$emailbody);


Similar Threads

  1. Extremely Simple PHP code needed! Help!!
    By Indiigo007 in forum PHP & Perl
    Replies: 6
    Last Post: 11-19-2012, 12:31 AM
  2. PHP/html Coder needed for simple code snippit
    By reinie in forum Hire a Freelancer
    Replies: 6
    Last Post: 03-06-2012, 02:41 PM
  3. [WTB] Help me setup simple adscendmedia file gateway php code! $10
    By wpbacklinks in forum Hire a Freelancer
    Replies: 0
    Last Post: 10-13-2010, 02:29 AM
  4. I need help with a simple PHP code
    By paymymortgage4me in forum PHP & Perl
    Replies: 6
    Last Post: 02-20-2009, 08:14 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




BlackHatWorld on Twitter BlackHatWorld on FaceBook


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108