Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    email php on windows xp

    hi, i'm new to php and i'm going a major project of php email for my school's major project. i've encounted some problems:

    1) i'm not sure whether my codes are correct
    2) i'm not sure whether if the hosting server does not support mail function, can i still use the mail function

    i've been cracking my brain on that for quite some time.

    ------------------------------------

    my php code loooks like this:
    Code:
    <?PHP
    if(($_GET['sender_name'] == "") || ($_GET['sender_email'] == "") || ($_GET['message'] == "")){
    	header("Location:contact.htm");
    	exit;
    }
    
    $email = $_REQUEST['sender_email'] ;
    $name = $_REQUEST['sender_name'] ;
    $message = $_REQUEST['message'] ;
    
    if (@mail("myaddress@domain.com","PBL Help Desk",$message))   
        echo 'Your request have been submitted.';
        else 
        echo '(Sorry, there has been an error...)';
    
    /*$to="myaddress@domaine.com";
    $subject="PBL Help Desk";
    
    $msg="E-MAIL SENT FROM PBL Site\n";
    $msg.="Sender's Name:\t$_POST[sender_name]\n";
    $msg.="Sender's E-Mail:\t$_POST[sender_email]\n";
    $msg.="Message:\t$_POST[message]\n";
    
    $mailheaders="From: My Site <myaddress@domaine.com>\n";
    $mailheaders.="Reply-To: $_POST[sender_email]\n";
    $mailheaders.="Message: $_POST[message]\n";
    mail($to,$subject,$msg,$mailheaders);*/
    
    ?>
    
    <html><head>
    <title>Online PBL Survival Kit</title>
    </head><body>
    <H1>You have entered the following information:</H1>
    <p><strong>Your Name:</strong><br>
    <? echo "$_GET[sender_name]"; ?>
    
    <p><strong>Your Email Address:</strong><br>
    <? echo "$_GET[sender_email]"; ?>
    
    <p><strong>Message:</strong><br>
    <? echo "$_GET[message]"; ?>
    
    </body></html>
    --------------------------

    and my html code looks like this:
    Code:
    <form action="helpdesk.php" method="GET" name="HelpDesk" id="HelpDesk">
                    <p>&nbsp;</p>
                    <p>From: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="sender_name" type="text" id="sender_name" size="20">
                      <br>
                      <br>
                      Your Email Address: &nbsp;&nbsp;
                      <input name="sender_email" type="text" id="sender_email" size="30">
                      <br>
                      <br>
                      Your message</p>
                    <p>
                      <textarea name="message" cols="50" wrap=virtual rows="10" id="message"></textarea>
    </p>
                    <p align="center">
                      <input type="submit" name="Submit" value="Submit">
                      <input name="Reset" type="submit" id="Reset" value="Reset"> 
                      </p>
                  </form></td>
    ----------------------------

    all the naming is correct and i am not sure what went wrong. when i click the submit button with all the fills filled, it printed all the error message together with the information that i've input in

    anyone please help out

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    if (@mail("myaddress@domain.com","PBL Help Desk",$message)) 
    The @ is suppressing any useful error messages, all you know from the error message generated by the code is that the mail didn't send, remove the @ and try the script and post back the error message it generates. If the server doesn't allow mail() then you can't use it, but the error may tell you if that's the problem here or something else.

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Check you have an smtp server installed on the system


  •  

    Posting Permissions

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