SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Member
    Join Date
    Aug 2013
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP form - blank emails

    Hello! I've been trying to get a submission form working where i can grab customers information and process it. I'd ideally like it in the following format

    Youtube name: namehere
    firstname: namehere
    lastname: name here
    email: emailhere

    etc

    At the moment i am getting a blank email with nothing in the email itself. The header works fine and it grabs the email and puts it in the "from:" I'm a noob to HTML and PHP and had someone do this but they are unavailable for quite a while so i need to get this fixed as soon as i can. The PHP contact form came with a theme that i purchased and it works fine in the HTML contact form that it was supplied with but i needed it changed to fit my requirements. Any help is appreciated, thanks in advance!

    My HTML code.

    HTML Code:
    					<form id="" action="application/application.php" method="post" class="validateform" name="send-contact">
    					 
    					 <div id="sendmessage">
    							Your message has been sent. Thank you!
    						</div>
    						
    						<input type="hidden" name="subject" value="Partnership  Applications" />
                            
                                                     Youtube Channel Name <br>
    						 <input type="text" name="ytname" placeholder="* Enter Your YouTube Name" data-rule="maxlen:4" data-msg="Please enter at least 4 chars"  /> 
    						 <div class="validation"></div>
                             
    						 First Name <br>
    						 <input type="text" name="firstname" placeholder="* Enter Your First Name" data-msg="Please enter at least 4 chars" /> 
    						 <div class="validation"></div>
    						 
    					          Last Name <br>
    						 <input type="text" name="lastname" placeholder="* Enter Your Last Name" data-msg="Please enter at least 4 chars" /> 
    						 <div class="validation"></div>
    						 
    						 Your Paypal Email Address <br>
    						 <input type="text" name="ppemail" placeholder="* Enter Your Paypal Email" data-msg="Please enter a valid email" /> 
    						 <div class="validation"></div>
    						 
    						 Your YouTube Email Address <br>
    						 <input type="text" name="email" placeholder="* Enter Your YouTube Email" data-msg="Please enter a valid email" /> 
    						 <div class="validation"></div>	
    
    						 Skype <br>
    						 <input type="text" name="skype" placeholder="* Enter Your Skype Name" data-msg="Please enter at least 4 chars"  /> 
    						 <div class="validation"></div>										 
    						 
    						 <!--<button class="btn btn-theme margintop10 pull-left" type="submit" name="submit" value="Send">Submit message</button>-->
    						   <span class="pull-right margintop20">* Please fill all required form field, thanks!</span>
    						   <BR>
    						   <BR>
    						   <b>FORM IN MAINTENANCE!PLEASE SEND ALL<br> INFORMATION ABOVE DIRECTLY TO<br> <a href="mailto:Support@xvinitynetwork.com">Support@XvinityNetwork.com</a></b>
    					
    
    						   </form>

    and this is my PHP

    PHP Code:
    <?php 
    ini_set
    ('display_errors',1); 
    error_reporting(E_ALL); 

    /*
    Credits: Bit Repository
    URL: http://www.bitrepository.com/
    */

    include 'config.php';

    error_reporting (E_ALL E_NOTICE);

    $post = (!empty($_POST)) ? true false;

    if(
    $post)
    {

    $ytname stripslashes($_POST['ytname']);
    $firstname stripslashes($_POST['firstname']);
    $lastname stripslashes($_POST['lastname']);
    $ppemail trim($_POST['ppemail']);
    $email trim($_POST['email']);
    $subject stripslashes($_POST['subject']);
    $skype stripslashes($_POST['skype']);


    $error '';



    if(!
    $error)
    {
    $mail mail(WEBMASTER_EMAIL$email$ytname,
         
    "From: ".$name." <".$email.">\r\n"
        
    ."Reply-To: ".$email."\r\n"
        
    ."X-Mailer: PHP/" phpversion());


    if(
    $mail)
    {
    echo 
    'OK';
    }

    }


    }
    ?>
    My config.php includes the following;

    PHP Code:
    <?php
    // To
    define("WEBMASTER_EMAIL"'Support@XvinityNetwork.com');
    ?>
    Thanks again

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,207
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Hi MrPie, welcome to the forums.

    The main issue here is that the $mail = part doesn't sent any of the data you have collected to the destination email. It should look something like this:

    Code PHP:
    $mail = mail(WEBMASTER_EMAIL, $subject, $body, $header);

    Then, above that line, paste this:

    Code php:
    $body = "Name: $firstname $lastname\r\n"  .
            "PayPal Email: $ppemail\r\n"  .
            "Skype Name: $skype\r\n"  .
            "Client Email: $email\r\n";
     
    $subject = "Your Chosen Email Subject";
     
    $header =  "From: " . $firstname $lastname . " <" .$email. ">\r\n" .
        "Reply-To: ".$email . "\r\n" .
        "X-Mailer: PHP/" . phpversion());

    Because you don't actually ask the user to type a subject, delete this line:

    Code php:
    $subject = stripslashes($_POST['subject']);

    and add in a subject of your choice in this line I gave you above:

    Code:
    $subject = "Your Chosen Email Subject";
    I'm not an expert at this stuff, but see if those changes help at all.

  3. #3
    SitePoint Member
    Join Date
    Aug 2013
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Ralph, thanks for the speedy reply and thanks for helping I'm a complete novice at this and i'm more of an art person rather than someone who codes lol

    Apologies if i've got this wrong. When you say one line up i thought you meant literally so i dont know what i did and didn't have to delete

    I have made the changes you've suggested but i'm now not receiving any email at all, not sure what could be the problem.


    PHP Code:
    <?php 
    ini_set
    ('display_errors',1); 
    error_reporting(E_ALL); 

    /*
    Credits: Bit Repository
    URL: http://www.bitrepository.com/
    */

    include 'config.php';

    error_reporting (E_ALL E_NOTICE);

    $post = (!empty($_POST)) ? true false;

    if(
    $post)
    {

    $body "Name: $firstname $lastname\r\n"  .
            
    "Youtube Name: $ytname/r\n" .
            
    "PayPal Email: $ppemail\r\n"  .
            
    "Skype Name: $skype\r\n"  .
            
    "Client Email: $email\r\n";
     
    $subject "Partnership Applications";
     
    $header =  "From: " $firstname $lastname " <" .$email">\r\n" .
        
    "Reply-To: ".$email "\r\n" .
        
    "X-Mailer: PHP/" phpversion());


    $error '';



    if(!
    $error)
    {

        
    $mail mail(WEBMASTER_EMAIL$subject$body$header);
         
    "From: ".$name." <".$email.">\r\n"
        
    ."Reply-To: ".$email."\r\n"
        
    ."X-Mailer: PHP/" phpversion());


    if(
    $mail)
    {
    echo 
    'OK';
    }

    }


    }
    ?>

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,207
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    I notice one back slash has become a forward slash here:

    Code:
    "Youtube Name: $ytname/r\n" .
    Make sure to fix that. But I was pretty specific about what to do. I didn't say anything about removing all this stuff:

    Code:
    $ytname = stripslashes($_POST['ytname']); 
    $firstname = stripslashes($_POST['firstname']); 
    $lastname = stripslashes($_POST['lastname']); 
    $ppemail = trim($_POST['ppemail']); 
    $email = trim($_POST['email']); 
    $subject = stripslashes($_POST['subject']); 
    $skype = stripslashes($_POST['skype']);
    So, in an attempt to be clearer:

    Replace this code:

    Code php:
    $mail = mail(WEBMASTER_EMAIL, $email, $ytname, 
         "From: ".$name." <".$email.">\r\n" 
        ."Reply-To: ".$email."\r\n" 
        ."X-Mailer: PHP/" . phpversion());

    with this code:

    Code PHP:
    $mail = mail(WEBMASTER_EMAIL, $subject, $body, $header);

    Then, above that line, paste this:

    Code php:
    $body = "Name: $firstname $lastname\r\n"  .
            "PayPal Email: $ppemail\r\n"  .
            "Skype Name: $skype\r\n"  .
            "Client Email: $email\r\n";
     
    $subject = "Your Chosen Email Subject";
     
    $header =  "From: " . $firstname $lastname . " <" .$email. ">\r\n" .
        "Reply-To: ".$email . "\r\n" .
        "X-Mailer: PHP/" . phpversion());

    Because you don't actually ask the user to type a subject, delete this line:

    Code php:
    $subject = stripslashes($_POST['subject']);

    from here:

    Code:
    $ytname = stripslashes($_POST['ytname']); 
    $firstname = stripslashes($_POST['firstname']); 
    $lastname = stripslashes($_POST['lastname']); 
    $ppemail = trim($_POST['ppemail']); 
    $email = trim($_POST['email']); 
    $subject = stripslashes($_POST['subject']);   // delete this line, but not the others!!!!!!!!!!!!!!!!
    $skype = stripslashes($_POST['skype']);

  5. #5
    SitePoint Member
    Join Date
    Aug 2013
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks again Ralph, i've made the changes you've mentioned but i am still not able to recieve any emails when the form is filled in

    Here's the PHP as it stands right now

    PHP Code:
    <?php 
    ini_set
    ('display_errors',1); 
    error_reporting(E_ALL); 

    /*
    Credits: Bit Repository
    URL: http://www.bitrepository.com/
    */

    include 'config.php';

    error_reporting (E_ALL E_NOTICE);

    $post = (!empty($_POST)) ? true false;

    if(
    $post)
    {

    $ytname stripslashes($_POST['ytname']);
    $firstname stripslashes($_POST['firstname']);
    $lastname stripslashes($_POST['lastname']);
    $ppemail trim($_POST['ppemail']);
    $email trim($_POST['email']);
    $skype stripslashes($_POST['skype']);


    $error '';



    if(!
    $error)
    {
    $body "Name: $firstname $lastname\r\n"  .
            
    "Youtube Name: $ytname\r\n" .
            
    "PayPal Email: $ppemail\r\n"  .
            
    "Skype Name: $skype\r\n"  .
            
    "Client Email: $email\r\n";
     
    $subject "Partnership Applications";
     
    $header =  "From: " $firstname $lastname " <" .$email">\r\n" .
        
    "Reply-To: ".$email "\r\n" .
        
    "X-Mailer: PHP/" phpversion());
        
    $mail mail(WEBMASTER_EMAIL$subject$body$header);


    if(
    $mail)
    {
    echo 
    'OK';
    }

    }


    }
    ?>

  6. #6
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,207
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    What happens if you change this:

    Code:
    $header =  "From: " . $firstname $lastname . " <" .$email. ">\r\n" . 
        "Reply-To: ".$email . "\r\n" . 
        "X-Mailer: PHP/" . phpversion());
    to this?

    Code:
    $header =  "From: " . $firstname $lastname . " <" .$email. ">\r\n" . 
        "Reply-To: ".$email;
    Are you getting any error messages?

  7. #7
    SitePoint Member
    Join Date
    Aug 2013
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure how to check for errors, completely new to this. I can say that after that change the emails are getting sent however there is no subject and the contents of the email itself is blank.

  8. #8
    SitePoint Member
    Join Date
    Aug 2013
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any help is still appreciated! I'm very confused as to why i am not receiving the $body to the email. I've fixed the "no subject" problem by adding the following code into the HTML but i still have no luck with the $body. I'd assume that the least it would do is send the fields with empty info but nada. I've also done some research which suggests that the $mail only works on Linux? so i double checked on Godaddy and we are on a Linux server, don't know if that helps or not!

    HTML Code:
    <input type="hidden" name="subject" value="Partnership  Application" />

  9. #9
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,207
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Sorry for the delay. I'm not a PHP guy, though I can do simple forms like this; but there are many ways to do them, and I don't think it's worth continuing with the code you have, as it's not great anyway. When I get time, if you like, I'll have a go at doing it a different way that I know will work, and which will include security features, too. But I have to give priority to paid work, so it might take a while.

  10. #10
    SitePoint Member
    Join Date
    Aug 2013
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Appreciate the help ralph! It's understandable. At the moment i just have a notice on the website to direct the information to my email. It would be great if i could get something working and it would mean a lot.

    If it helps. This is the other form that came with the theme and it works perfectly for sending simple messages to me and such

    PHP Code:
    <?php
    /*
    Credits: Bit Repository
    URL: http://www.bitrepository.com/
    */

    include 'config.php';

    error_reporting (E_ALL E_NOTICE);

    $post = (!empty($_POST)) ? true false;

    if(
    $post)
    {

    $name stripslashes($_POST['name']);
    $email trim($_POST['email']);
    $subject stripslashes($_POST['subject']);
    $message stripslashes($_POST['message']);


    $error '';



    if(!
    $error)
    {
    $mail mail(WEBMASTER_EMAIL$subject$message,
         
    "From: ".$name." <".$email.">\r\n"
        
    ."Reply-To: ".$email."\r\n"
        
    ."X-Mailer: PHP/" phpversion());


    if(
    $mail)
    {
    echo 
    'OK';
    }

    }


    }
    ?>
    Thanks again Ralph. I'll keep scouring the internet for any solutions in the meantime.

  11. #11
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,207
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Oh, your last post gives me a clue as to the problem, actually. Try this:

    Code php:
     
    <?php 
    /* 
    Credits: Bit Repository 
    URL: [url]http://www.bitrepository.com/[/url] 
    */ 
     
    include 'config.php'; 
     
    error_reporting (E_ALL ^ E_NOTICE); 
     
    $post = (!empty($_POST)) ? true : false; 
     
    if($post) 
    { 
     
    $ytname = stripslashes($_POST['ytname']); 
    $firstname = stripslashes($_POST['firstname']); 
    $lastname = stripslashes($_POST['lastname']); 
    $ppemail = trim($_POST['ppemail']); 
    $email = trim($_POST['email']); 
    $skype = stripslashes($_POST['skype']);  
     
     
    $error = ''; 
     
    $body = "Name: $firstname $lastname\r\n"  . 
            "Youtube Name: $ytname\r\n" . 
            "PayPal Email: $ppemail\r\n"  . 
            "Skype Name: $skype\r\n"  . 
            "Client Email: $email\r\n"; 
     
    $subject = "Partnership Applications"; 
     
    if(!$error) 
    { 
    $mail = mail(WEBMASTER_EMAIL, $subject, $body, 
         "From: ".$firstname $lastname ." <".$email.">\r\n" 
        ."Reply-To: ".$email."\r\n" 
        ."X-Mailer: PHP/" . phpversion()); 
     
    if($mail) 
    { 
    echo 'OK'; 
    } 
     
    } 
     
     
    } 
    ?>

  12. #12
    SitePoint Member
    Join Date
    Aug 2013
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm still nothing. I get no subject with just the php form. But having the following in the HTML solves this problem;

    HTML Code:
    <input type="hidden" name="subject" value="Partnership  Application" />
    As for the code. Still nothing. I'm starting to wonder if this is a problem on GoDaddys email service or something....

    Hmmph just dug this up. Hopefully it helps

    You are able to use custom scripts for sending emails, and you will want to ensure that you are using relay-hosting.secureserver.net as the SMTP server. This relay server does not require authentication.

    If you use the mail() fuction, it will not need to be specified.
    and this is interesting

    Thanks for the follow up with your experience. It is recommended that the ‘From’ address you are using in your script be an address using your hosted domain.
    Just an FYI. The email i use (Support@XvinityNetwork.com) is from GoDaddy


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
  •