I need a php mail file made

Discussion in 'PHP' started by pavelbarchuk, May 30, 2009.

  1. #1
    I made a clone of a page from a different website, now i need to make a php mailform file.

    You can see the contact form on this page -> http://www.advancedcarpentryinc.com/request-a-bid.htm/

    do you guys know how to make the php file so when you click submit it would go to the email that i want to?
     
    pavelbarchuk, May 30, 2009 IP
  2. liammarksmith

    liammarksmith Peon

    Messages:
    14
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yes, Heres Mine:

    
    <?php
    	if($_POST['Send']){
    		
    		$Name = $_POST['Name'];
    		$Email = $_POST['Email'];
    		$Subject = $_POST['Subject'];
    		$Detail = $_POST['Messgae'];
    		
    		if(!$Name){
    			
    			$Error =  'Sorry, You left the <b>name</b> field blank, This field is required. [<a href="contact.php">Go back</a>]';
    			
    		}else{
    			
    			if(!$Email){
    				
    				$Error = 'Sorry, You left the <b>email</b> field blank, This field is required. [<a href="contact.php">Go back</a>]';
    				
    			}else{
    				
    				if(!$Detail){
    						
    						$Error =  'Sorry, You left the <b>Message</b> field blank, This field is required. [<a href="contact.php">Go back</a>]';
    				}else{
    					
    					$Message = "
    Message From: ".$Email."
    -------------------------------------------------------
    
    ".$Detail;
    					
    					mail('YourEmailHere', $Subject, $Message, "From: $Email");
    					
    					echo 'You`re Message has Been Sent [<a href="index.php">Go back Home</a>]';
    			}
    		}
    	}
    }
    	
     ?>
    <form id="form2" name="form2" method="post" action="">
      <table width="100%" border="0">
      
        <tr>
          <td colspan="2"><strong>Contact Us</strong></td>
        </tr>
        <?php if($Error and $_POST['Send']){ echo '
                <tr>
                  <td colspan="2"><div class="error">'.$Error.'</div></td>
                  </tr>
    			  ';
    			  } ?>
        <?php if($Success and $_POST['Send']){ echo '
                <tr>
                  <td colspan="2"><b>'.$Success.'</b></td>
                  </tr>
    			  ';
    			  } ?>
        <tr>
          <td width="17%"><strong>Your Name</strong></td>
          <td width="83%"><input name="Name" type="text" id="Name" value="" size="60" /></td>
        </tr>
        <tr>
          <td><strong>Your Email</strong></td>
          <td><input name="Email" type="text" id="Email" value="" size="60" /></td>
        </tr>
        <tr>
          <td><strong>Subject</strong></td>
          <td><input name="Subject" type="text" id="Subject" size="60" /></td>
        </tr>
        <tr>
          <td valign="top"><strong>Message:</strong></td>
          <td><textarea name="Message" id="Message" cols="60" rows="5"></textarea></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><input type="submit" name="Send" value="Send"  /></td>
        </tr>
      </table>
    </form>
    
    PHP:
    Change the email and form as you require, if you need any further assistance be sure to let me know.

    Hope my 2nd/3rd post can be of help to someone!
    Liam Smith
     
    liammarksmith, May 30, 2009 IP