Jump to content

Php contact form (mailer.php)


andyroo123

Recommended Posts

Hi guys,

I'm new to this forum, I need some help with a contact form, I've done ones before.. but I need someone to make me a mailer.php file that would suffice this framework for my html coded form. The form also has css, which I can't give out, but I'm sure you coders don't really need to see the form.

 

Basically I would also want this progress bar to work correctly. I can't see to get it all right.

 

                    <div id="maincontent">
                    <h2>Contact</h2>
                    <div id="main_form">
                        <p id="loadBar" style="display:none;">
                            <strong>Sending Email. Hold on just a sec&#8230;</strong><br />
                            <img src="images/loading.gif" alt="Loading..." title="Sending Email" />
                        </p>
                        <p id="emailSuccess" style="display:none;">
                            <strong style="color:red;">Success! Your Email has been sent.</strong>
                        </p>
                        <div id="contactFormArea">
                            <form action="mailer.php" method="post" id="cForm">
                                <fieldset>
                                    <label for="posName">Name:</label>
                                    <input class="input-textarea" type="text" size="25" name="posName" id="posName" /><br /><br />
                                    <label for="posEmail">Email:</label>
                                    <input class="input-textarea" type="text" size="25" name="posEmail" id="posEmail" /><br /><br />
                                    <label for="posRegard">Subject:</label>
                                    <input class="input-textarea" type="text" size="25" name="posRegard" id="posRegard" /><br /><br />
                                    <label for="posText">Message:</label>
                                    <textarea cols="50" rows="5" name="posText" id="posText"></textarea><br /><br />
                                    <label for="selfCC">
                                        <!--<input type="checkbox" name="selfCC" id="selfCC" value="send" /> Send CC to self-->
                                        <input type="hidden" name="selfCC" id="selfCC" value="xxx" />
                                    </label>
                                    <label>
                                        <input class="input-submit"  type="submit" name="sendContactEmail" id="sendContactEmail" value=" Send Email " />
                                    </label>
                                </fieldset>
                            </form>
                        </div>
                    </div>

 

Thanks in advance,

Andy

Link to comment
https://forums.phpfreaks.com/topic/213835-php-contact-form-mailerphp/
Share on other sites

Try this... very easily adaptable with simple php.

 

<BODY>
<FONT SIZE="2" FACE="ARIAL">
<?php
$nasaadresa = "[email protected]";  //please replace this with your address

$mail = $_POST['Email'];
$porukaa = $_POST['Message'];
$poruka = str_replace("\r", '<br />', $porukaa);
//START OF THANKS MESSAGE
//you may edit $thanks message. this is a message which displays when user sends mail from your site
$thanks = "
<p align='left'><br>
<b>Your message has successfully been sent and we will contact you as soon as we can.  Many Thanks!<br></b>
<br>
You will receive a copy of the message at your email address <b>($mail).<br>A member of our team will reply to you as soon as possible<br></b></p>";
//do not edit nothing below this line  until comment (ME) say so if you don't have skills with PHP
//END OF THANKS MESSAGE

if($_POST['submitform']) 
{

$Name = $_POST['Name'];
$Email = $_POST['Email'];
$Message = $_POST['Message'];
$Phone = $_POST['Phone'];
$Regarding = $_POST['Regarding'];
$require = $_POST['require'];
$browser = $HTTP_USER_AGENT;
$ip = $_SERVER['REMOTE_ADDR'];

$dcheck = explode(",",$require);
while(list($check) = each($dcheck)) 
{
	if(!$$dcheck[$check]) {
	$error .= "You have not filled this field(s): <b>$dcheck[$check]</b>.<br>";
	}
}
if ((!ereg(".+\@.+\..+", $Email)) || (!ereg("^[[email protected]]+$", $Email))){
$error .= "Wrong e-mail.<br>This e-mail address <b>$Email</b> - is not valid. Please enter correct e-mail address.";
}
if($error)
{
echo $error;
echo '<br><a href="#" onClick="history.go(-1)">Please try again.</a>';
}
else
{
//START OF INCOMING MESSAGE (this message goes to your inbox)
$message = "
Name: $Name:
E-mail: $Email
Phone Number: $Phone

Subject: $Regarding

Message: $Message

-----------------------------
Browser: $browser
IP: $ip
";
//END OF INCOMING MESSAGE (this message goes to your inbox)

$subject = "Message from www.BarryOttleyMotorCo.co.uk - Message was sent by $Name"; //subject OF YOUR INBOX MESSAGE sent to you

$subject2 = "You have successfully sent message from www.BarryOttleyMotorCo.co.uk!"; //subject of OUTGOING MESSAGE - edit this
//OUTGOING MESSAGE TEXT
$message2 = "You have sent a message to www.BarryOttleyMotorCo.co.uk:
-----------------------------
Name: $Name:
E-mail: $Email
Phone Number: $Phone

Subject: $Regarding

Message: $Message

-----------------------------
";
//END OF outgoing MESSAGE


mail($nasaadresa,"$subject","$message","From: $Name <$Email>");
mail($Email,"$subject2","$message2","From: <$nasaadresa>");
echo "$thanks";
}
}
else{
//this is contact form down here, please edit if you know what are you doing... or the contact form may not be working.
echo '
<br>
<form name="contactform" action="'.$PHP_SELF.'" method="post">
<input type="hidden" name="require" value="Name,Email,Message">
  <table width="100%" align="center">
    <tr>
      <td colspan="2" align="center">
        <p></td>
    </tr>
    <tr>
      <td valign="top" align="right"><FONT FACE="ARIAL" SIZE="2"><b>Name:</b></td>
      <td valign="top">
        <input name="Name" size="30">
      </td>
    </tr>

    <tr>
      <td valign="top" align="right"><FONT FACE="ARIAL" SIZE="2"><b>Telephone Number:</b></td>
      <td valign="top">
        <input name="Phone" size="30"><BR><BR>
      </td>
    </tr>
    <tr>
      <td valign="top" align="right"><FONT FACE="ARIAL" SIZE="2"><b>E-mail:</b></td>
      <td valign="top">
        <input name="Email" size="30">
      </td>
    </tr>
    <tr>
      <td valign="top" align="right"><FONT FACE="ARIAL" SIZE="2"><b>Subject:</b></td>
      <td valign="top">
<select name="Regarding">
<option value="GeneralEnquiry">General Enquiry</option>
<option value="WouldLikeToBuyACar">Would like to buy a car</option>
<option value="WouldLikeToKnowMore">Would like to know more about a car</option>
<option value="PleaseCallBack">Request a call back</option>
</select>

      </td>
    </tr>


    <tr>
      <td valign="top" align="right"><FONT FACE="ARIAL" SIZE="2"><b>Message:</b></td>
      <td valign="top">
        <textarea name="Message" rows="10" cols="30"></textarea>
      </td>
    </tr>
    <tr>
      <td colspan="2" align="center"><p align="center"><br>
        <input type="submit" value="Send Message to www.BarryOttleyMotorCo.co.uk" name="submitform">
        <input type="reset" value="Reset" name="reset"></p>
      </td>
    </tr>
  </table>
</form>';
}
?>

Thanks for your submission, but I'm looking for someone to code the progress part correctly for me, 'cos I don't seem to get it right, the other parts are pretty simple.

 

It just needs to send a request and recieve one back confirming that it is correct, I believe.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.