dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: mail() problem

  1. #1
    Join Date
    Nov 2003
    Location
    Canada
    Posts
    1,592

    mail() problem

    Hell all. I am having troubles with a mail form on my site, located here. When I go to send the mail, it just sits there loading for a while, and then eventually gives me an error saying somethign like "This document contains no data". Here is the source code for the script:

    The form:
    Code:
    <div id='mailform'>
    <form action='mail.php' method='post'>
    <div>
    	<div>
    		<label for='mname'>Name:<span class='asterix'> *</span></label>
    		<input onfocus="style.borderColor='#000000';" onblur="style.borderColor='#cccccc';" type='text' name='mname' id='mname' />
    	</div>
    	<div class='center'>
    		<label for='memail'>Your e-mail:<span class='asterix'> *</span></label>
    		<input onfocus="style.borderColor='#000000';" onblur="style.borderColor='#cccccc';" type='text' name='memail' id='memail' />
    	</div>
    	<div>
    		<label for='msub'>Subject<span class='asterix'> *</span></label>
    		<input onfocus="style.borderColor='#000000';" onblur="style.borderColor='#cccccc';" type='text' name='msub' id='msub' />
    	</div>
    	<div class='center'>
    		<label for='mcom'>Comment:<span class='asterix'> *</span></label>
    		<textarea onfocus="style.borderColor='#000000';" onblur="style.borderColor='#cccccc';" name='mcom' id='mcom' cols='30' rows='5'></textarea>
    	</div>
    	<div style="border-bottom:2px solid #ddd;">
    		<input onmousedown="style.backgroundColor='#dddddd'" onmouseup="style.backgroundColor='#ffffff'" onblur="style.backgroundColor='#ffffff'" onmouseover="style.backgroundColor='#eeeeee'" onmouseout="style.backgroundColor='#fff'" type='submit' value='Submit Comment' class='button' />
    		<input onmousedown="style.backgroundColor='#dddddd'" onmouseup="style.backgroundColor='#ffffff'" onblur="style.backgroundColor='#ffffff'" onmouseover="style.backgroundColor='#eeeeee'" onmouseout="style.backgroundColor='#fff'" type='reset' value='Reset Form' class='button' />
    	</div>
    </div>
    </form>
    </div>
    And the PHP on the mail.php page:
    PHP Code:
    <?php    
        $name 
    $_REQUEST['mname'];
        
    $email $_REQUEST['memail'];
        
    $sub $_REQUEST['msub'];
        
    $comment $_REQUEST['mcom'];
            
        
    // makes sure no required fields were left blank
        
    if($name == "" || $email == "" || $comment == "" || $sub == "")
        {
            print(
    "One or more of the required fields was not filled in. Please go back and try again.");
            include(
    'includes/footer.xml');
            exit;
        }
        
    mail("dandaman_91@yahoo.ca"$sub"$name\n$email\n$com");
    ?>
    Here is the lines in my php.ini file that refer to the mail function:
    [mail function]
    ; For Win32 only.
    SMTP = 216.36.173.149
    smtp_port = 80

    ; For Win32 only.
    sendmail_from = dandaman_91@yahoo.ca
    I am running PHP v5.0.0RC1 off of Apache 2 on Windows XP. Can someone tell me what I've done wrong?
    -Dan

  2. #2
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    700
    I'd try replacing $_REQUEST with $_POST to read the incoming data as follows;

    <?php
    $name = $_POST['mname'];
    $email = $_POST['memail'];
    $sub = $_POST['msub'];
    $comment = $_POST['mcom'];

    // makes sure no required fields were left blank
    if($name == "" || $email == "" || $comment == "" || $sub == "")
    {
    print("One or more of the required fields was not filled in. Please go back and try again.");
    include('includes/footer.xml');
    exit;
    }
    mail("dandaman_91@yahoo.ca", $sub, "$name\n$email\n$com");
    ?>

    CTB

  3. #3
    Join Date
    Nov 2003
    Location
    Canada
    Posts
    1,592
    OK, I switched that, but it still isn't working. Any more suggestions?
    -Dan

  4. #4
    Join Date
    Feb 2004
    Location
    Slovenia
    Posts
    230
    Try with this script:
    PHP Code:
    <?php    
        $name 
    $_POST['mname'];
        
    $email $_POST['memail'];
        
    $sub $_POST['msub'];
        
    $comment $_POST['mcom'];
            
        
    // makes sure no required fields were left blank
        
    if($name == "" || $email == "" || $comment == "" || $sub == "")
        {
            print(
    "One or more of the required fields was not filled in. Please go back and try again.");
            include(
    'includes/footer.xml');
            exit;
        }
        if (
    mail("dandaman_91@yahoo.ca"$sub$name."\n".$email."\n".$com)){
    echo 
    "Done";
    }else {
    echo 
    "Failed";
    }
    ?>
    If this doesn't work try with simple mail script.
    PHP Code:
    mail("Mail.mail@hotmail.com""Subject""Message"); 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles