Need help with PHP contact form

Hi guys,
I've made a PHP contact form for my site and need help with a couple of things:
The form action links an external PHP script (scripts/contact-form-script.php) but is there a way I can have it so the PHP script for the form is contained within the same PHP file as my contact form (contact.php)?
I tried just putting the form code at the top of contact.php but the browser automatically reads the anti-spam re-direct, so maybe that needs revising too?
The second thing is, how can I make the Name, Email and Message fields mandatory? So if a user tries to submit the form and hasn't filled in one of the required fields and clicks submit, contact.php reloads with a message at the top of the form saying something like 'Complete the required fields' and highlights the relevant field with a red border?
Here's the code for contact.php:
<form action="http://www.mydomain.com/scripts/contact-form-script.php" method="post" name="contact" id="contact">
<p><strong>Name:*</strong><br />
<input name="name" type="text" class="ctextField" /></p>
<p><strong>E-mail:*</strong><br />
<input name="email" type="text" class="ctextField" /></p>
<p><strong>Telephone:</strong><br />
<input name="telephone" type="text" class="ctextField" /></p>
<p><strong>Company:</strong><br />
<input name="company" type="text" class="ctextField" /></p>
<p><strong>Address:</strong><br />
<input name="address1" type="text" class="ctextField" /></p>
<p><input name="address2" type="text" class="ctextField" /></p>
<p><strong>Town:</strong><br />
<input name="town" type="text" class="ctextField" /></p>
<p><strong>County:</strong><br />
<input name="county" type="text" class="ctextField" /></p>
p><strong>Postcode:</strong><br />
<input name="postcode" type="text" class="ctextField" /></p>
<p><strong>Message:*</strong><br />
<textarea name="message" cols="55" rows="8" class="ctextField"></textarea></p>
<p><input name="submit" value="SEND MESSAGE" class="submitButton" type="submit" /><div style="visibility:hidden; width:1px; height:1px"><input name="url" type="text" size="45" id="url" /></div></p>
</form>
And this is the PHP I'm using to submit the form data for contact-form-script.php:
<?php
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$to = "[email protected]";
$subject = "Contact from website";
$message = $headers;
$message .= "Name: " . $_POST["name"] . "\r\n";
$message .= "E-mail: " . $_POST["email"] . "\r\n";
        $message= '
            <table cellspacing="0" cellpadding="8" border="0" width="500">
            <tr>
                <td colspan="2"></td>
            </tr>
            <tr bgcolor="#eeeeee">
              <td width="154" style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Name</strong></td>
              <td width="314" style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$name.'</td>
            </tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>E-mail address:</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$email.'</td>
            </tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Telephone number:</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$telephone.'</td>
            </tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Company:</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$company.'</td>
            </tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Address</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$address1.'</td>
            </tr>
            <tr bgcolor="#eeeeee">
              <td></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$address2.'</td>
            </tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Town</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$town.'</td>
            </tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>County</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$county.'</td>
            </tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Postcode</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$postcode.'</td>
            </tr>
            <tr bgcolor="#eeeeee">
                <td colspan="2" style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Message</strong></td>
            </tr>              
            <tr bgcolor="#eeeeee">
                <td colspan="2" style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$message.'</td>
            </tr>              
            <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
         </table>
$url = stripslashes($_POST["url"]);
if (!empty($url)) {
header( 'Location: http://www.go-away-spam-robots.com' );
exit();
mail($to, $subject, $message, $headers);
header( 'Location: http://www.mydomain.com/sent.php' ) ;
?>
Any help on this would be greatly appreciated.
Thank you and I hope to hear from you!
SM

Revised code with form validation for Name Email and Message:
<?php
if (array_key_exists('submit', $_POST)) {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $telephone = $_POST['telephone'];
    $company = $_POST['company'];
    $address1 = $_POST['address1'];
    $address2 = $_POST['address2'];
    $town = $_POST['town'];
    $county = $_POST['county'];
    $postcode = $_POST['postcode'];
    $formMessage = $_POST['message'];
if (empty($name)) {
                                            $warning['name'] = "Please provide your name";
if (empty($email)) {
                                            $warning['email'] = "Please provide your email";
if (empty($formMessage)) {
                                            $warning['message'] = "Please provide your message";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$to = "[email protected]";
$subject = "Contact from website";
$message = $headers;
$message .= "Name: " . $_POST["name"] . "\r\n";
$message .= "E-mail: " . $_POST["email"] . "\r\n";
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
        $message= "
<table cellspacing='0' cellpadding='8' border='0' width='500'>
            <tr>
                <td colspan='2'></td>
            </tr>
            <tr bgcolor='#eeeeee'>
              <td width='154' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Name</strong></td>
              <td width='314' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$name."</td>
            </tr>
            <tr bgcolor='#eeeeee'>
              <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>E-mail address:</strong></td>
              <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$email."</td>
            </tr>
            <tr bgcolor='#eeeeee'>
              <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Telephone number:</strong></td>
              <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$telephone."</td>
            </tr>
            <tr bgcolor='#eeeeee'>
              <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Company:</strong></td>
              <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$company."</td>
            </tr>
            <tr bgcolor='#eeeeee'>
              <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Address</strong></td>
              <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$address1."</td>
            </tr>
            <tr bgcolor='#eeeeee'>
              <td></td>
              <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$address2."</td>
            </tr>
            <tr bgcolor='#eeeeee'>
              <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Town</strong></td>
              <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$town."</td>
            </tr>
            <tr bgcolor='#eeeeee'>
              <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>County</strong></td>
              <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$county."</td>
            </tr>
            <tr bgcolor='#eeeeee'>
              <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Postcode</strong></td>
              <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$postcode."</td>
            </tr>
            <tr bgcolor='#eeeeee'>
                <td colspan='2' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Message</strong></td>
            </tr>              
            <tr bgcolor='#eeeeee'>
                <td colspan='2' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$formMessage."</td>
            </tr>              
            <tr><td colspan='2' style='padding: 0px;'><img src='images/whitespace.gif' alt='' width='100%' height='1' /></td></tr>
         </table>
$url = stripslashes($_POST["url"]);
if (!empty($url)) {
header( 'Location: http://www.go-away-spam-robots.com' );
exit();
if (!isset($warning)) {
mail($to, $subject, $message, $headers);
header( 'Location: http://www.mydomain.com/sent.php' ) ;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<style type="text/css">
p {
    margin: 0;
    padding: 10px 0 0 0;
.warning {
    color:#C00;
</style>
</head>
<body>
<form action="" method="post" name="contact" id="contact">
<p><strong>Name:*</strong><br />
<input name="name" <?php if (isset($warning['name'])) { echo "style='border: 1px solid #C00'"; } ?> type="text" class="ctextField" />
<?php if (isset($warning['name'])) { echo "<p class='warning'>".$warning['name']."</p>"; }?>
</p>
<p><strong>E-mail:*</strong><br />
<input name="email" <?php if (isset($warning['email'])) { echo "style='border: 1px solid #C00'"; } ?>type="text" class="ctextField" />
<?php if (isset($warning['name'])) { echo "<p class='warning'>".$warning['email']."</p>"; }?>
</p>
<p><strong>Telephone:</strong><br />
<input name="telephone" type="text" class="ctextField" /></p>
<p><strong>Company:</strong><br />
<input name="company" type="text" class="ctextField" /></p>
<p><strong>Address:</strong><br />
<input name="address1" type="text" class="ctextField" /></p>
<p><input name="address2" type="text" class="ctextField" /></p>
<p><strong>Town:</strong><br />
<input name="town" type="text" class="ctextField" /></p>
<p><strong>County:</strong><br />
<input name="county" type="text" class="ctextField" /></p>
<p><strong>Postcode:</strong><br />
<input name="postcode" type="text" class="ctextField" /></p>
<p><strong>Message:*</strong><br />
<?php if (isset($warning['message'])) { echo "<p class='warning'>".$warning['message']."</p>"; }?>
<textarea name="message" <?php if (isset($warning['message'])) { echo "style='border: 1px solid #C00'"; } ?> cols="55" rows="8" class="ctextField"></textarea></p>
<p><input name="submit" value="SEND MESSAGE" class="submitButton" type="submit" /><div style="visibility:hidden; width:1px; height:1px"><input name="url" type="text" size="45" id="url" /></div></p>
</form>
</body>
</html>

Similar Messages

  • Need help with php registration form! (Dreamweaver cs5)

    Im creating an advanced php registration form in dreamweaver. I need the following code for:
    ZIP / Postal code, date of birth.
                      or
    if u can help me how to create the entire form with the following fields That will be nice! Im a Newbie:
    First name, lastname, country, zip / postal code, date of birth, username, password, email, verified, and token.
    This is the database i have in mysql:
    User_id, INT, (10), UNSIGNED, NOT NULL, A_INCREMENT
    Firstname, VARCHAR, (50), NOT NULL
    Lastname, VARCHAR, (50), NOT NULL
    Country, VARCHAR, (20), NOT NULL
    Zip, INT, (12), NOT NULL
    Birth_date, DATE, NOT NULL    
    Username, VARCHAR, (15), NOT NULL
    Password, VARCHAR, (40), NOT NULL
    Email, VARCHAR, (100), NOT NULL
    Verified, ENUM, ('n','y'), NOT NULL
    Token, VARCHAR, (40), NOT NULL
    I need to know how to apply the insert recorset server behavior in dreamweaver cs5 so I can get it to run.
    I have been trying diff ways and i just can't get it right.
    Please help! Thanks!!!

    I'm not sure how much you know but first you have to connect your form to the database
    $con = mysql_connect("hostname","admin_name","password");
    Then you have to choose the database you want information be added to.
    mysql_select_db("database name goes here", $con);
    Then you have to write an sql function which will write it in the appropiate columns in your database
    $sql="INSERT INTO what column e.g members (First name, Last name, age, etc)
    VALUES (the names of the textfields on your form), actually double check that part
    ('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";
    $result = mysql_query($sql);
    This is the first and most basic part just to give you an idea how it works.
    Within these snippets you will have to write much more which will beef up the security aswell as check if everything has been entered correctly etc

  • Help with php contact form

    I built a form in Dreamweaver CS4 which looks and seems to work fine both in IE and FF. I then wrote the PHP script and uploaded it to my hosting site. When I fill in the form on the web, I get my "thank you" email stating I will contact them in 24 - 48 hours. I also get this from the hosting site - This email was sent using the PHP mail() function. If you received this email than the PHP mailer is working fine. With all that said my problem is that I do not get a copy of the form details. On the properties section in Dreamweaver, I have the Form ID as contactus and Action connecting to my folder - ../Contactform.php, but I have the target blank. What would it be - blank, parent or self or should it just be black?
    Thanks in advance for any help. 

    target="_blank" opens a page in a new window. It is not used for forms processing.
    For a form, when you begin it, you need to tell it what's going to happen:
    <form method="post" action="Contactform.php">
    (And, actually, I don't recommend the use of upper and lower-case characters in any file that is to be called by a web server, bu that is not related to your issue.)
    Then, you will have an action button at the bottom of your form:
    <input type="submit" value=" Contact Me" />
    When that action button (or submit button) is activated on your web page, it should query the form for what to do. In the case that I'm outlining here, the action is to run the php file you have called Contactform.php.
    At that point, your php code takes over and will do something.
    In your php, do you have something like this?
    $subject = Contact_from_your_webpage;
    $notes = stripcslashes($notes);
    $message = " $todayis [EST] \n
    Message: $notes \n
    From: $visitor ($visitormail)\n
    Telephone: $visitorphone ($visitorphone)\n
    From: $visitor ($visitormail)\n
    Address: $address1 ($address1)\n
    Address: $address2 ($address2)\n
    From: $city $state  $zip\n
    $from = "From: $visitormail\r\n";
    mail("[email protected]", $subject, $message, $from);
    This should send you an email with all of the stuff you put in your form to send
    Please understand that, in this case, I am using form fields that may be different from yours (you didn't provide us with a link, so I don't know what your form fields are). My fields are as follows:
    visitor
    visitormail
    visitorphone
    address1
    address2
    city
    state
    zip
    notes
    I am going to hazard a guess that, either you didn't tell your form to do the right thing or your php is wrong.
    -Mark

  • Need help with Adobe Interactive Form Saving

    Hi Gurus,
    I need your help with Adobe Interactive form saving.
    I have written the code in pre-save event to prompt a message when user didn't enter any value before saving. The form data should not be saved upon clicking save (Just prompt the message and exit form the form). Can u please advice me how to do this.
    Regards,
    Srini

    see the link: http://forms.stefcameron.com/2008/04/
    it says:
    preSave: Failed validations will not prevent the form from being saved however Acrobat/Reader will issue a special warning message, after issuing the validation error message, to inform the user that the validations failed. Iu2019m guessing this is because the user may be saving the form to continue filling it at a later time so the save canu2019t be completely prevented.
    regards,
    BJagdishwar.

  • Need Help with PHP please!!!

    I'm trying to create a contact us page and my web host needs it in php and I have no clue how to do it.
    I am using Dreamweaver Cs3 I have flash but am new to it.
    Thank You
    LB 

    it will be a learning curve, but look into david's books, http://foundationphp.com/index.php. He goes through all your php contact form step by step, I am still using one that I did in dw 8 book.

  • Need help with PHP form with checkboxes, radio buttons and file attachment

    Hi guys,
    I'm having a nightmare with this PHP form where a user can fill it in, attach a doc/pdf and submit. After trying to sort it out with previous code I've used, I've stripped it out and think I should just start again in the hope you geniuses can help!
    Here is the HTML of contact.php:
    <form action="" method="post" name="contact" id="contact">
        <p>Job Title:*<br />
        <input name="position" type="text" /></p>
        <p>Nationality:*<br />
        <select name="nationality">
          <option value="">-- select one --</option>
          <option value="Afghan">Afghan</option>
          <option value="Albanian">Albanian</option>
          <option value="Algerian">Algerian</option>
          <option value="Zambian">Zambian</option>
          <option value="Zimbabwean">Zimbabwean</option>
        </select>
        </p>
        <p>Which country are you currently living in?*<br />
        <select name="country">
        <option value="">-- select one --</option>
        <option value="United Kingdom">United Kingdom</option>
        <option value="Afghanistan">Afghanistan</option>
        <option value="Africa">Africa</option>
        <option value="Zambia">Zambia</option>
        <option value="Zimbabwe">Zimbabwe</option>
        </select>
        </p>
        <label class="radio" for="checkRight">Yes/No question?</label><br />
        <input class="radio" type="radio" name="right" value="Yes" /> Yes
        <input class="radio" type="radio" name="right" value="No" /> No
        <input class="radio" type="radio" name="right" value="N/A" /> Not applicable
        <p>Yes/No question?<br />
        <select name="continue">
        <option value="">-- select one --</option>
        <option value="Yes">Yes</option>
        <option value="No">No</option>
        </select>
        </p>
        <p>Select your resorts:<br />
        Resort 1<input name="res1" type="checkbox" value="Resort 1" />
        Resort 2<input name="res2" type="checkbox" value="Resort 2" />
        Resort 3<input name="res3" type="checkbox" value="Resort 3" />
        Resort 4<input name="res4" type="checkbox" value="Resort 4" />
        Resort 5<input name="res5" type="checkbox" value="Resort 5" />
        Resort 6<input name="res6" type="checkbox" value="Resort 6" />   
        </p>
        <p>Don't send form unless this is checked:* <input type="checkbox" name="parttime" value="Yes" /></p>
        <p>Date of arrival: <input name="arrive" id="datepick" /><br />
        Date of departure: <input name="depart" id="datepick2" /></p>
        <script type="text/javascript" src="assets/scripts/datepickr/datepickr.js"></script>
        <link href="assets/scripts/datepickr/datepickr.css" rel="stylesheet">
        <script type="text/javascript">
        new datepickr('datepick');
        new datepickr('datepick2', {
        </script>
        <p>Name:*<br />
        <input name="name" type="text" /></p>
        <p>E-mail:*<br />
        <input name="email" type="text" /></p>
        <p>Telephone:*<br />
        <input name="telephone" type="text" class="ctextField" /></p>
        <p>Upload CV (Word of PDF formats only):<br />
        <input type="file" name="cv" class="textfield"></p>
        <p><input name="submit" value="Submit Enquiry" class="submitButton" type="submit" /><div style="visibility:hidden; width:1px; height:1px"><input name="url" type="text" size="45" id="url" /></div></p>
    </form>
    By the way, the date boxes work so excuse the Javascript in there!
    To prevent SPAM I've used a trick where there's a hidden URL field which must be left blank for the form to submit which you can see in the PHP.
    Below is where I'm at with the PHP which is placed above the header of contact.php...
    <?php
    if (array_key_exists('submit', $_POST)) {
        $position = $_POST['position'];
        $arrive = $_POST['arrive'];
        $nationality = $_POST['nationality'];
        $parttime = $_POST['parttime'];
        $depart = $_POST['depart'];
        $name = $_POST['name'];
        $email = $_POST['email'];
        $telephone = $_POST['telephone'];
    $to = "[email protected]";
    $subject = "Recruitment Application";
    $message = $headers;
    $message .= "Name: " . $_POST["name"] . "\r\n";
    $message .= "E-mail: " . $_POST["email"] . "\r\n";
    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "Reply-To: " . $_POST["email"] . "\r\n";
    $headers .= 'From: My Website <[email protected]>' . "\r\n";
    $message= "
    $url = stripslashes($_POST["url"]);
    if (!empty($url)) {
    header( 'Location: http://www.go-away-spam-robots.com' );
    exit();
    if (!isset($warning)) {
    mail($to, $subject, $message, $headers);
    header( 'Location: http://www.mywebsite.co.uk/sent.php' );
    ?>
    I would like to make pretty much all the field compulsory so if a field is left empty (other than the hidden URL field), a warning message is displayed next to that field.
    Also I would like the file upload field to attach to the email that is sent to me and have the results come through to me in a table format.
    Can anyone help me get my form working?
    Thank you and I hope to hear from you!
    SM

    Hi Nancy,
    Great stuff, thank you for the reply.
    I've managed to get the Formm@iler working and running as I need it to.
    The only thing I'm struggling with is when the user clicks submit, they are taken to a page of whatever results the form returned but it is just a white background with Times New Roman text.
    How can I have it so the user is taken to the form results in the websites' page layout?
    I tried sending them to a generic 'thank you' page by adding the following code but it just took them there whatever the results of the form so that's no good...! I have a feeling it's a bit more complicated than that...
    header( 'Location: http://www.nofussbus.co.uk/test/sent.php' );
    Thank you for your help!

  • Help with custom contact form

    hey... i have been trying to cr8 a custom contact me from:
    the code inside the flash movie declares the variable's and
    sends them
    on the othere hand i ahve also added the code inside the php
    script which is currently
    just trying to catch some of the varible's unsuccsesfully
    can anyone help me with this? i am not strong with php and
    thats my problem

    ef: http://www.aocroswell.com/aocroswellnew/site_flash/index-6-testcontact.html
    You have 6 opening <form> tags with several levels of wrongness about them.
    They are nested in a most confusing way.
    You have 4 closing </form> tags for those 6 opening tags.
    <form action="/aocroswellnew/contact.asp" id="form">
    <form>
    <form name="contact_form" action="contact.php" method="get">
    <form action="contact.php" method="get">
    <form id="form" method="post"  target=”_blank” action="contact.asp" name="form">
    <form id="form" method="post"  target=”_blank” action="contact.asp" name="form" >
    And I haven't even started on the controls you have (and don't have) inside some of those forms.
    You cannot have multiple instances of identical ids in a Web page.
    Try this.
    Decide ahead of time whether you want to use PHP or ASP for the action attribute.
    Decide ahead of time whether you want to use GET or POST for the method attribute.
    Create a new page in DW according to your chosen action attribute (and the path to an existing script to process this action).
    Create a new form in that page and fill in the action and method attributes as appropriate.
    Create your input controls and your button controls, giving them names, ids, and possibly labels. The names & ids may need to match whatever your script is expecting to see (I don't read asp).
    Now look at this page in Code view to see how a form should look.
    http://www.w3.org/TR/html401/interact/forms.html#h-17.1
    Mark A. Boyd
    Keep-On-Learnin' :-)
    Message was edited by: Mark A. Boyd

  • Need help with PHP mail script

    I  have created a  log in system  . In that when the  user completes the  registration process an auto reply(auto-reply@domain)  will generate and  sent this to users email id regarding about the user  name and password  (Lo gin Details). After formal approval from the admin  the user will  get a user activation mail with log in link.
    But , my problem is  these are work only for mail accounts from my  domain  only(test@domain). its not send any of above mentioned details  to other  mail services like gmail or yahoo etc.
    i discussed this   with some others, they said its the problem with your mail function   configuration. but i didn't get any needful information as am a  beginner  in PHP scripting.
    i have contacted this with my  hosting service they said its the  problem with  php mail () function  and use php mailer() instead mail().
    please give me a solution for the same..
    Here am ataching my code..
    <?php
    include 'dbc.php';
    $err = array();
    if($_POST['doRegister'] == 'Register')
    foreach($_POST as $key => $value) {
        $data[$key] = filter($value);
    if(empty($data['full_name']) || strlen($data['full_name']) < 4)
    $err[] = "ERROR - Invalid name. Please enter atleast 3 or more characters for your name";
    //header("Location: register.php?msg=$err");
    //exit();
    // Validate User Name
    if (!isUserID($data['user_name'])) {
    $err[] = "ERROR - Invalid user name. It can contain alphabet, number and underscore.";
    //header("Location: register.php?msg=$err");
    //exit();
    // Validate Email
    if(!isEmail($data['usr_email'])) {
    $err[] = "ERROR - Invalid email address.";
    //header("Location: register.php?msg=$err");
    //exit();
    // Check User Passwords
    if (!checkPwd($data['pwd'],$data['pwd2'])) {
    $err[] = "ERROR - Invalid Password or mismatch. Enter 5 chars or more";
    //header("Location: register.php?msg=$err");
    //exit();
    $user_ip = $_SERVER['REMOTE_ADDR'];
    // stores sha1 of password
    $sha1pass = PwdHash($data['pwd']);
    // Automatically collects the hostname or domain  like example.com)
    $host  = $_SERVER['HTTP_HOST'];
    $host_upper = strtoupper($host);
    $path   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    // Generates activation code simple 4 digit number
    $activ_code = rand(1000,9999);
    $usr_email = $data['usr_email'];
    $user_name = $data['user_name'];
    $rs_duplicate = mysql_query("select count(*) as total from users where user_email='$usr_email' OR user_name='$user_name'") or die(mysql_error());
    list($total) = mysql_fetch_row($rs_duplicate);
    if ($total > 0)
    $err[] = "ERROR - The username/email already exists. Please try again with different username and email.";
    if(empty($err)) {
    $sql_insert = "INSERT into `users`
                  (`full_name`,`user_email`,`pwd`,`address`,`tel`,`fax`,`website`,`date`,`users_ip`,`activa tion_code`,`country`,`user_name`
                VALUES
                ('$data[full_name]','$usr_email','$sha1pass','$data[address]','$data[tel]','$data[fax]',' $data[web]'
                ,now(),'$user_ip','$activ_code','$data[country]','$user_name'
    mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error());
    $user_id = mysql_insert_id($link); 
    $md5_id = md5($user_id);
    mysql_query("update users set md5_id='$md5_id' where id='$user_id'");
    //    echo "<h3>Thank You</h3> We received your submission.";
    if($user_registration)  {
    $a_link = "
    *****ACTIVATION LINK*****\n
    http://$host$path/activate.php?user=$md5_id&activ_code=$activ_code
    } else {
    $a_link =
    "Your account is *PENDING APPROVAL* and will be soon activated the administrator.
    $message =
    "Hello \n
    Thank you for registering with us. Here are your login details...\n
    User ID: $user_name
    Email: $usr_email \n
    Passwd: $data[pwd] \n
    $a_link
    Thank You
    Administrator
    $host_upper
    THIS IS AN AUTOMATED RESPONSE.
    ***DO NOT RESPOND TO THIS EMAIL****
        mail($usr_email, "Login Details", $message,
        "From: \"Member Registration\" <auto-reply@$host>\r\n" .
         "X-Mailer: PHP/" . phpversion());
      header("Location: thankyou.php"); 
      exit();
    ?>

    I  have created a  log in system  . In that when the  user completes the  registration process an auto reply(auto-reply@domain)  will generate and  sent this to users email id regarding about the user  name and password  (Lo gin Details). After formal approval from the admin  the user will  get a user activation mail with log in link.
    But , my problem is  these are work only for mail accounts from my  domain  only(test@domain). its not send any of above mentioned details  to other  mail services like gmail or yahoo etc.
    i discussed this   with some others, they said its the problem with your mail function   configuration. but i didn't get any needful information as am a  beginner  in PHP scripting.
    i have contacted this with my  hosting service they said its the  problem with  php mail () function  and use php mailer() instead mail().
    please give me a solution for the same..
    Here am ataching my code..
    <?php
    include 'dbc.php';
    $err = array();
    if($_POST['doRegister'] == 'Register')
    foreach($_POST as $key => $value) {
        $data[$key] = filter($value);
    if(empty($data['full_name']) || strlen($data['full_name']) < 4)
    $err[] = "ERROR - Invalid name. Please enter atleast 3 or more characters for your name";
    //header("Location: register.php?msg=$err");
    //exit();
    // Validate User Name
    if (!isUserID($data['user_name'])) {
    $err[] = "ERROR - Invalid user name. It can contain alphabet, number and underscore.";
    //header("Location: register.php?msg=$err");
    //exit();
    // Validate Email
    if(!isEmail($data['usr_email'])) {
    $err[] = "ERROR - Invalid email address.";
    //header("Location: register.php?msg=$err");
    //exit();
    // Check User Passwords
    if (!checkPwd($data['pwd'],$data['pwd2'])) {
    $err[] = "ERROR - Invalid Password or mismatch. Enter 5 chars or more";
    //header("Location: register.php?msg=$err");
    //exit();
    $user_ip = $_SERVER['REMOTE_ADDR'];
    // stores sha1 of password
    $sha1pass = PwdHash($data['pwd']);
    // Automatically collects the hostname or domain  like example.com)
    $host  = $_SERVER['HTTP_HOST'];
    $host_upper = strtoupper($host);
    $path   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    // Generates activation code simple 4 digit number
    $activ_code = rand(1000,9999);
    $usr_email = $data['usr_email'];
    $user_name = $data['user_name'];
    $rs_duplicate = mysql_query("select count(*) as total from users where user_email='$usr_email' OR user_name='$user_name'") or die(mysql_error());
    list($total) = mysql_fetch_row($rs_duplicate);
    if ($total > 0)
    $err[] = "ERROR - The username/email already exists. Please try again with different username and email.";
    if(empty($err)) {
    $sql_insert = "INSERT into `users`
                  (`full_name`,`user_email`,`pwd`,`address`,`tel`,`fax`,`website`,`date`,`users_ip`,`activa tion_code`,`country`,`user_name`
                VALUES
                ('$data[full_name]','$usr_email','$sha1pass','$data[address]','$data[tel]','$data[fax]',' $data[web]'
                ,now(),'$user_ip','$activ_code','$data[country]','$user_name'
    mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error());
    $user_id = mysql_insert_id($link); 
    $md5_id = md5($user_id);
    mysql_query("update users set md5_id='$md5_id' where id='$user_id'");
    //    echo "<h3>Thank You</h3> We received your submission.";
    if($user_registration)  {
    $a_link = "
    *****ACTIVATION LINK*****\n
    http://$host$path/activate.php?user=$md5_id&activ_code=$activ_code
    } else {
    $a_link =
    "Your account is *PENDING APPROVAL* and will be soon activated the administrator.
    $message =
    "Hello \n
    Thank you for registering with us. Here are your login details...\n
    User ID: $user_name
    Email: $usr_email \n
    Passwd: $data[pwd] \n
    $a_link
    Thank You
    Administrator
    $host_upper
    THIS IS AN AUTOMATED RESPONSE.
    ***DO NOT RESPOND TO THIS EMAIL****
        mail($usr_email, "Login Details", $message,
        "From: \"Member Registration\" <auto-reply@$host>\r\n" .
         "X-Mailer: PHP/" . phpversion());
      header("Location: thankyou.php"); 
      exit();
    ?>

  • Help with a contact form script

    I have this contact form but it doesn't send the email
    this is the page www.vonhaucke.mx
    and the script for contacto.php is:
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>.:vonhaucke:.</title>
    <link href="contacto.css" rel="stylesheet" type="text/css" media="screen" />
    </head>
    <body>
    <table align="center" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="372"> </td>
        <td width="278" class="margen"><div id="logo" class="logo"><img src="img/logovonhaucke.png" width="228" height="71" alt="Vonhaucke" title="Vonhaucke"></div></td>
      </tr>
      <tr>
        <td style="border-bottom:#CCC solid 1px; border-top:#CCC solid 1px;"><h1>Contacto</h1></td>
        <td style="border-bottom:#CCC solid 1px; border-left:#CCC solid 1px; border-top:#CCC solid 1px;"> </td>
      </tr>
      <tr>
        <td valign="top" align="right">
      <div id="contact" align="right">   
      <form action="enviar.php" method="post">
      <label for="name">Nombre:</label>
      <input type="text" name="nombre" /><br />
      <label for="name">Apellido:</label>
      <input type="text" name="apellido" /><br />
      <label for="name">Empresa:</label>
      <input type="text" name="empresa" /><br />              
      <label for="email">Email:</label>
      <input type="email" name="mail" /><br />
      <label for="name">Página web:</label>
      <input type="text" name="web" /><br />
      <label for="name">Teléfono:</label>
      <input type="text" name="telefono" /><br />                       
      <label for="message">Comentarios:</label>
      <textarea name="comentarios"></textarea><br />
      <input type="submit" value="Enviar" />
      </form>
        </div>
        </td>
        <td class="margen">
            <div id="direccion">
                <strong>Sala de Exhibición y Oficinas</strong><br />Paseo de la Reforma 284 PH<br />
                Col. Juárez Del Cuauhtémoc<br />06600 México DF<br />T :: 5999 9200<br />
               www.vonhaucke.mx<br />       
                <strong>Aguascalientes</strong><br />T :: 014499145150.<br />E-mail :: [email protected]<br />
                <strong>Bajio</strong><br />T :: 014422150577.<br />E-mail :: [email protected]<br />
                <strong>Cancún</strong><br />T :: 019988920272.<br />E-mail :: [email protected]<br />
                <strong>Hidalgo</strong><br />T :: 0445539243356.<br />E-mail :: [email protected]<br />
                <strong>Puebla</strong><br />T :: 012224661905.<br />E-mail :: [email protected]<br />
                <strong>Toluca</strong><br />T :: 017222714990.<br />E-mail :: [email protected]<br />
                <strong>Nueva York</strong><br />(800) 7113572<br />Sherry Mitchel Inc. Vonhaucke<br />P.O. Box 3035<br />Sea Bright, N,J. 07760
            </div> <br />
        </td>
      </tr>
      <tr>
        <td colspan="2" align="center">
        <div id="ubicacion">Paseo de la Reforma 284 PH, Col. Juárez, Del. Cuauhtémoc, C.P. 06600, México D.F. T.(55) 5999 9200, e-mail. [email protected]</div>
        </td>
      </tr>
    </table>
    </body>
    </html>
    the script for enviar.php is
    <?php
    $nombre = $_POST['nombre'];
    $apellido=$_POST['apellido'];
    $empresa = $_POST['empresa'];
    $mail = $_POST['mail'];
    $web = $_POST['web'];
    $telefono = $_POST['telefono'];
    $comentarios = $_POST['comentarios'];
    $header = 'From: ' . $mail . " \r\n";
    $header .= "X-Mailer: PHP/" . phpversion() . " \r\n";
    $header .= "Mime-Version: 1.0 \r\n";
    $header .= "Content-Type: text/plain";
    $mensaje = "Este mensaje fue enviado por " . $nombre ." ". $apellido. ", de la empresa " . $empresa . ", Sitio web: " . $web . " \r\n";
    $mensaje .= "Su e-mail es: " . $mail . " \r\n";
    $mensaje .= "Mensaje: " . $_POST['comentarios'] . " \r\n";
    $mensaje .= "Enviado el " . date('d/m/Y', time());
    $para = '[email protected]';
    $asunto = 'Comentarios desde sitio web: vonhaucke';
    mail($para, $asunto, utf8_decode($mensaje), $header);
    //echo 'Mensaje enviado correctamente';
    ?>
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>.:vonhaucke:.</title>
    <link href="contacto.css" rel="stylesheet" type="text/css" media="screen" />
    </head>
    <body>
    <table align="center" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="372"> </td>
        <td width="278" class="margen"><div id="logo" class="logo"><img src="img/logovonhaucke.png" width="228" height="71" alt="Vonhaucke" title="Vonhaucke"></div></td>
      </tr>
      <tr>
        <td style="border-bottom:#CCC solid 1px; border-top:#CCC solid 1px;"><h1>Contacto</h1></td>
        <td style="border-bottom:#CCC solid 1px; border-left:#CCC solid 1px; border-top:#CCC solid 1px;"> </td>
      </tr>
      <tr>
        <td valign="top" align="right">
      <div id="contact" align="right">   
      <form action="#" method="post">
      <p align="center">Mensaje enviado correctamente</p>
            <input type="button" onClick="parent.$.modal().close()" value="Cerrar">
      </form>
        </div>
        </td>
        <td class="margen">
            <div id="direccion">
                <strong>Aguascalientes</strong><br />T :: 014499145150.<br />E-mail :: [email protected]<br />
                <strong>Bajio</strong><br />T :: 014422150577.<br />E-mail :: [email protected]<br />
                <strong>Cancún</strong><br />T :: 019988920272.<br />E-mail :: [email protected]<br />
                <strong>Hidalgo</strong><br />T :: 0445539243356.<br />E-mail :: [email protected]<br />
                <strong>Puebla</strong><br />T :: 012224661905.<br />E-mail :: [email protected]<br />
                <strong>Toluca</strong><br />T :: 017222714990.<br />E-mail :: [email protected]<br />
                <strong>Nueva York</strong><br />(800) 7113572<br />Sherry Mitchel Inc. Vonhaucke<br />P.O. Box 3035<br />Sea Bright, N,J. 07760
            </div> <br />
        </td>
      </tr>
      <tr>
        <td colspan="2" align="center">
        <div id="ubicacion">Paseo de la Reforma 284 PH, Col. Juárez, Del. Cuauhtémoc, C.P. 06600, México D.F. T.(55) 5999 9200, e-mail. [email protected]</div>
        </td>
      </tr>
    </table>
    </body>
    </html>
    I don't know why is not sending the email to [email protected]

    Your script works ok when I test it out - the information is sent to the specified email address - although I don't know what the below code has to do with it all? (I've blanked the email addresses to avoid spam)
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>.:vonhaucke:.</title>
    <link href="contacto.css" rel="stylesheet" type="text/css" media="screen" />
    </head>
    <body>
    <table align="center" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="372"> </td>
        <td width="278" class="margen"><div id="logo" class="logo"><img src="img/logovonhaucke.png" width="228" height="71" alt="Vonhaucke" title="Vonhaucke"></div></td>
      </tr>
      <tr>
        <td style="border-bottom:#CCC solid 1px; border-top:#CCC solid 1px;"><h1>Contacto</h1></td>
        <td style="border-bottom:#CCC solid 1px; border-left:#CCC solid 1px; border-top:#CCC solid 1px;"> </td>
      </tr>
      <tr>
        <td valign="top" align="right">
      <div id="contact" align="right">   
      <form action="#" method="post">
      <p align="center">Mensaje enviado correctamente</p>
            <input type="button" onClick="parent.$.modal().close()" value="Cerrar">
      </form>
        </div>
        </td>
        <td class="margen">
            <div id="direccion">
                <strong>Aguascalientes</strong><br />T :: 014499145150.<br />E-mail :: xxxxxxxxx@xxxxxxxx<br />
                <strong>Bajio</strong><br />T :: 014422150577.<br />E-mail :: xxxxxxxxx@xxxxxxxx<br />
                <strong>Cancún</strong><br />T :: 019988920272.<br />E-mail :: xxxxxxxxx@xxxxxxxx<br />
                <strong>Hidalgo</strong><br />T :: 0445539243356.<br />E-mail :: xxxxxxxxx@xxxxxxxx<br />
                <strong>Puebla</strong><br />T :: 012224661905.<br />E-mail :: xxxxxxxxx@xxxxxxxx<br />
                <strong>Toluca</strong><br />T :: 017222714990.<br />E-mail :: xxxxxxxxx@xxxxxxxx<br />
                <strong>Nueva York</strong><br />(800) 7113572<br />Sherry Mitchel Inc. Vonhaucke<br />P.O. Box 3035<br />Sea Bright, N,J. 07760
            </div> <br />
        </td>
      </tr>
      <tr>
        <td colspan="2" align="center">
        <div id="ubicacion">Paseo de la Reforma 284 PH, Col. Juárez, Del. Cuauhtémoc, C.P. 06600, México D.F. T.(55) 5999 9200, e-mail. xxxxx@xxxxxx</div>
        </td>
      </tr>
    </table>
    </body>
    </html>

  • Need help with Automatic Generating Form Numbers

    Hello,
    I am new to all this and have found myself stuck trying to figure out how to have my forms automatiacally generate a new number each time it is used. I tried looking through similar posts but do not understand the directions given there. If someone could help me figure this out I would really appreciate it. Thank you.

    Before opening my forms for responses I am creating a column with my starting form number - 1.  in the cell above(first response) I am setting an equation =B2 +1.  All incoming responses automatically generate an ID number within my responses table.  The form itself will not present the number, but if you were looking for an easy way to track responses w/ an ID it has worked well for me so far.

  • Help with this contact form.

    Hi there
    I need help modifying a servlet to send email using a smtp home base internet connection,,(Sympatico)
    with a username and password... and server name (smtp)
    I am also using mysql with email parameters
    This is my servlet
    package ca.ccf.messaging;
    import java.util.Properties;
    import java.util.Date;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.Service;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    import ca.ccf.db.DBConfig;
    public class MessagingUtils {
         public enum Email {EASTHAWKS_CONTACT}
         public static final String SMTP_SERVER = "localhost";
         private static final String SQL_EMAIL = "SELECT " +
              DBConfig.CONTACT_EMAIL + " FROM " + DBConfig.CONTACT_EMAIL_TABLE +
              " WHERE " +     DBConfig.CONTACT_SECTION_ID + "=?";
         private static final String ERROR_MSG_EMAIL =
              "The recipient email address needs to be set";
         public static void sendMessage(Connection conn, Email from, Email to,
                   String subject, String text)
         throws SQLException, MessagingException {
              String emailTo = getEmail(conn, to);
              if (emailTo == null)
                   throw new MessagingException(ERROR_MSG_EMAIL);
              sendMessage(conn, from, emailTo, subject, text);
         public static void sendMessage(Connection conn, Email from, String to,
                   String subject, String text)
         throws SQLException, MessagingException {
              String emailFrom = getEmail(conn, from);
              if (emailFrom == null)
                   throw new MessagingException(ERROR_MSG_EMAIL);
              Properties props = new Properties();
              props.put("mail.smtp.host", SMTP_SERVER);
              Session session = Session.getDefaultInstance(props);
              Message message = new MimeMessage(session);
              InternetAddress addrTo = new InternetAddress(to, true);
              InternetAddress addrFrom = new InternetAddress(emailFrom, true);
              message.setFrom(addrFrom);
              message.addRecipient(Message.RecipientType.TO, addrTo);
              message.setSubject(subject);
              message.setText(text);
              message.setSentDate(new Date());
              try {
                   Transport.send(message);
              catch (Exception e) {
                   // TODO: handle exception
         private static String getEmail(Connection conn, Email email)
         throws SQLException {
              String addr = null;
              PreparedStatement pstmt = conn.prepareStatement(SQL_EMAIL);
              switch (email) {
              case EASTHAWKS_CONTACT:
                   pstmt.setInt(1, DBConfig.EASTHAWKS_CONTACT);
                   break;
              ResultSet rs = pstmt.executeQuery();
              if (rs.next())
                   addr = rs.getString(1);
              rs.close();
              pstmt.close();
              return addr;
    }

    I need help modifying a servlet to send email using a smtp home base internet connection,,(Sympatico)
    with a username and password... and server name (smtp)obtain the name of the 'Sympatico' smtp server and use it as your SMTP_SERVER, you can't use localhost because I guess you don't have a smtp server at home....
    This is my servletNo, thats not a servlet.
    I can't comment on the code because you have not enclosed your code in code tags, like this {code}your code hereThanks!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Really need help with basic static forms?!?!

    I was thrown into creating forms for our Business Managers and I am not a developer in any way!  I am a Recruiter, but somewhat tech savvy (or at least I thought I was). 
    I am trying to create basic static forms.  I started by using Adobe Professional and them moved to LiveCycle Designer because of what I thought were better "editable" options when creating the form.  I want to be able to send my manager's forms via e-mail (PDF), they can enter the requesting information in the fields, save a copy for themselves, print, and e-mail to me.  We are not using any of the Adobe Server things, I don't want them to submit via an e-mail button on the form.  We are a non-profit organization and my managers are using all different versions of reader. 
    I am getting extremely frustrated because in testing the form everything seems to be working properly including tab order, print, save and everything I want it to do.  Then, I send them out for my managers to use, for some Manager's they work great, no problems at all!  But then, I keep getting these weird issues from different Managers with the same form.  For one of them, what they typed in the field, now looks like it's behind the text box, like when you select Highlight all, you can see what he typed, but then if you click into the text box, you can see what he typed. Another Manager said, two (crucial) fields would not show the text entered when she tries to save or print, but on screen you can see it????
    So after the rambling, I guess my questions are: should I be using Live Cycle to create such basic forms or should I be using Adobe?  Can anyone recommend a good "FOR DUMMIES" book that will help me figure out what I am doing wrong, and not explain in "IT" language?
    This is really getting embarrassing!! Any help would be greatly appreciated!!!!

    1. Make sure to set the PDF target version. Goto File -> Form Properties (see the first screenshot attached)
         Find out the minimum Reader version used in your organization and set this value accordingly. If you are not sure, select the least recent version.
    2. two (crucial) fields would not show the text entered when she tries to save or print, but on screen you can see it
         This may be due to the visibility settings of the fields. Just make sure that you have selected visible instead of visible (screen only)
         See the second screenshot attached
    Hope this may help you.
    Nith

  • Need help with receiving offline form in GP

    I'm new to GP and interactive forms on EP 7.0 SP15 and running into a problem with submitting an offline form and GP starting the process.   The examples were followed on how to set up the callable object with an interactive form.  I've got the form set up to be used as a standalone interactive form and starting a process upon completion.  I've selected the process which is active and completed the mapping.  Went through the steps to manage impersonalized interactive forms.  Downloaded the form, entered data and submit.  Get the message back that it was received successfully.  Went back and checked manage impersonalized... and can see that the form was returned.  Go back to Runtime and can't find the process listed anywhere.  Where is it going?  Is there a way to track it down?  Looked at Maintain queues and checked each queue, can't find anything with a timestamp around the time the last form was submitted.  Any ideas on how to figure this out would be appreciated.
    Thank you,
    Kathy

    Thanks for the reply! I was able to reset the field calculation order
    but have one field that is not populating right away and I have
    changed it's order everywhere?

  • Need help with PHP form processor coding

    I posted my first question on this forum earlier today and got help quickly. I'm going to try again and see who can help me this time.
    I have a customer feedback form that I designed and I am using Spry validation on the fields and I'm use Recaptcha as well. Now I'm trying to get the form handler working. I know there are some canned procedures out there but I hate using too much code that I don't understand at all.  I'm sure my first attempt at PHP coding is horrible but we all have to learn. My processor is working in some areas but there are holes I don't know how to fill in:
    1. When I validate the Recaptcha input, if it was entered correctly, I go on to send an email to the appropriate person BUT how do I send them a message and get back to the form if the recaptcha validation fails and still have their entries in place?
    2. Assuming the recaptcha validated correctly, my procedure sends an email  and it writes the comments to a file for historical purposes. These parts seem to be working (by some miracle). Once I do this, I think I would like to open a little window to send the customer a confirmation message, have them click the box to confirm and close the window and then take them back to the feedback form but now have it be reset. I'm not sure how to do these steps.
    Does anyone have a SIMPLE example to accomplish these steps?
    Thanks much!!
    Donna

    It would be hard to give you substantive examples of how to accomplish your goals here without seeing your PHP code, but in general the following methods would work:
    1.  To return to the form with the fields populated, is easiest when the processing script and the form code are on the same page.  The idea is that when the form is not properly completed, you fall back into the form code and use the data from the posted values to repopulate the fields, e.g.,
    <input type="text' name="whatever" value="<?php isset($_POST['whatever']) { echo $_POST['whatever']; ?>">
    or
    <select name="whatever2">
    <option<?php if(isset($_POST['whatever2']) && $_POST['whatever2']=='this_option_value') { echo ' selected="selected"'; } ?>>this_option_value</option>
    </select>
    Each field is set to repeat the posted data (if the corresponding $_POST value is set - to avoid error messages when the page is first loaded).
    2.  You can place the confirmation message on the page with CSS that hides it.  When the form is submitted successfully, just set a variable that is used to show the previously hidden message, e.g.,
    Assume the following CSS -
    #message { display:none; }
    and the following HTML -
    <p id="message">Congratulations</p>
    and the fact that you have set a PHP variable called $success to be true when the form is successfully submitted, you would just modify the HTML like this -
    <p id="message"<?php if($success) { echo ' style="display:block"; } ?>>Congratulations</p>
    Make sense?

  • Need help with PHP mail script [was: Can someone please help me?]

    I'm trying to collect data from a form and email it.  I'm using form2mail.php and the problem is that the email is not collecting the form info and it has the same email address in the From: and To: lines. I'm really stuck and would appreciate any help.
    Here is the HTML code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Contact Us</title>
    <style type="text/css">
    <!--
    .style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
    .style2 {
    font-size: 14px;
    color: #000000;
    body {
    background-color: #FFFFFF;
    body,td,th {
    color: #CC3300;
    .style3 {font-size: 14px; font-weight: bold; }
    .style6 {font-size: 18px}
    .style7 {font-size: 16px}
    .style8 {font-size: 16px; font-family: Verdana, Arial, Helvetica, sans-serif; }
    .style9 {font-size: 16px; font-weight: bold; font-family: Verdana, Arial, Helvetica, sans-serif; }
    .style10 {color: #000000}
    -->
    </style>
    </head>
    <body>
    <div align="center"><img src="nav2.jpg" alt="nav bar" width="698" height="91" border="0" usemap="#Map2" />
      <map name="Map2" id="Map2">
      <area shape="rect" coords="560,9,684,38" href="accessories.html" />
    <area shape="rect" coords="456,8,548,38" href="contact.html" />
    <area shape="rect" coords="305,8,435,40" href="photog.html" />
    <area shape="rect" coords="187,9,283,39" href="services.html" />
    <area shape="rect" coords="81,10,167,39" href="aboutus.html" />
    <area shape="rect" coords="5,10,68,39" href="index.html" />
    </map>
      <map name="Map" id="Map">
        <area shape="rect" coords="9,9,69,39" href="index.html" />
        <area shape="rect" coords="83,11,165,39" href="aboutus.html" />
        <area shape="rect" coords="182,9,285,38" href="services.html" />
        <area shape="rect" coords="436,14,560,37" href="contact.html" />
        <area shape="rect" coords="563,14,682,38" href="accessories.html" />
      </map>
    </div>
    <p> </p>
    <form id="TheForm" name="TheForm" action="form2mail.php" method="post">
      <p align="center" class="style2">P<span class="style1">lease fill out form below for a &quot;free no obligation quote&quot; then click submit.</span></p>
      <p align="center" class="style3">(*Required Information)</p>
      <div align="center">
        <pre><strong><span class="style8">*Contact Name</span> </strong><input name="name" type="text" id="name" />
    <span class="style8"><strong>
    Business Name </strong></span><input name="bn" type="text" id="bn" />
    <span class="style8"><strong>*Phone Number <input type="text" name="first" size="3" onFocus="this.value='';"
        onKeyup="checkNumber(this.value); autoTab(this, document.TheForm.second);" maxlength="3" value="###" /> - <input type="text" name="second" size="3" onFocus="this.value='';" onKeyup="checkNumber(this.value); autoTab(this, document.TheForm.third);" maxlength="3" value="###" /> - <input type="text" name="third" size="4" onFocus="this.value='';" onKeyup="checkNumber(this.value); autoTab(this, document.TheForm.fourth);" maxlength="4" value="####"/> </strong></span>
    <strong><span class="style1">*</span><span class="style8">Email Address</span> <input name="email" type="text" id="email" />     </strong> </pre>
        <label><span class="style9">*Re-enter to confirm</span>
        <input name="emx" type="text" id="emx" /></label><br /><br /><span class="style9">
    <label></label>
        </span>
        <p><span class="style9">*Best time to call </span>
          <select name="name1[]" multiple size="1" >
            <option>8am-9am</option>
            <option>9am-10am</option>
            <option>10am-11am</option>
            <option>11am-12pm</option>
            <option>12pm-1pm</option>
            <option>1pm-2pm</option>
            <option>2pm-3pm</option>
            <option>3pm-4pm</option>
            <option>4pm-5pm</option>
            <option>5pm-6pm</option>
            <option>6pm-7pm</option>
            <option>7pm-8pm</option>
          </select>
          <br />
          <br />
          <span class="style9">Type of Location</span>
          <select name="name2[]" multiple size="1" >
            <option>Residential</option>
            <option>Commercial</option>
          </select>
          <br />
          <br />
            <span class="style1"><br />
            <strong><br />
              <span class="style6">*Type of Services Requested:</span></strong><br />
            </span><strong><span class="style10">(check all that apply)</span><br />
                </strong><br />
                <span class="style7"><span class="style1"><strong>Janitorial cleaning</strong></span>
                <input type="checkbox" name="checkbox[]" value="checkbox" multiple/>
                <br />
                </span><strong><br />
                  <span class="style8">Mobile Auto Detailing</span>
                <input type="checkbox" name="checkbox2[]" value="checkbox" multiple/>
                <br />
                <br />
                  </strong><span class="style9">Moving/Hauling</span>
          <input type="checkbox" name="checkbox3[]" value="checkbox" multiple/>
          <br />
          <br />
                  <span class="style9">Pressure washing</span>
          <input type="checkbox" name="checkbox4[]" value="checkbox" multiple/>
          <br />
          <br />
                  <span class="style9">Window washing</span>
          <input type="checkbox" name="checkbox5[]" value="checkbox" multiple/>
          <br />
          <br />
                  <span class="style9">Window Tinting</span>
          <input type="checkbox" name="checkbox6[]" value="checkbox" multiple/>
          <br />
          <br />
                  <span class="style9">Boat cleaning</span>
          <input type="checkbox" name="checkbox7[]" value="checkbox" multiple/>
          <br />
          <br />
                  <span class="style9">RV cleaning</span>
          <input type="checkbox" name="checkbox8[]" value="checkbox" multiple/>
          <br />
          <br />
                  <span class="style9">Motorcycle cleaning</span>
          <input type="checkbox" name="checkbox9[]" value="checkbox" multiple/>
          <br />
          <br />
          <br />
          <br />
          <input name="SB"  type="button" class="style9" value="Submit" onClick="sendOff();">
        </p>
      </div></label>
      <script language="JavaScript1.2">
    // (C) 2000 www.CodeLifter.com
    // http://www.codelifter.com
    // Free for all users, but leave in this  header
    var good;
    function checkEmailAddress(field) {
    // Note: The next expression must be all on one line...
    //       allow no spaces, linefeeds, or carriage returns!
    var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org) |(\..{2,2}))$)\b/gi);
    if (goodEmail){
       good = true
    } else {
       alert('Please enter a valid e-mail address.')
       field.focus()
       field.select()
       good = false
    function autoTab(startPoint,endPoint){
    if (startPoint.getAttribute&&startPoint.value.length==startPoint.getAttribute("max length"))
    endPoint.focus();
    function checkNumber(phoneNumber){
    var x=phoneNumber;
    var phoneNumber=/(^\d+$)|(^\d+\.\d+$)/
    if (phoneNumber.test(x))
    testResult=true
    else{
    alert("Please enter a valid number.")
    phoneNumber.focus();
    phoneNumber.value="";
    testResult=false
    return (testResult)
    function sendOff(){
       namecheck = document.TheForm.name.value   
       if (namecheck.length <1) {
          alert('Please enter your name.')
          return
       good = false
       checkEmailAddress(document.TheForm.email)
       if ((document.TheForm.email.value ==
            document.TheForm.emx.value)&&(good)){
          // This is where you put your action
          // if name and email addresses are good.
          // We show an alert box, here; but you can
          // use a window.location= 'http://address'
          // to call a subsequent html page,
          // or a Perl script, etc.
          window.location= 'form2mail.php';
       if ((document.TheForm.email.value !=
              document.TheForm.emx.value)&&(good)){
              alert('Both e-mail address entries must match.')
    </script>
    </form>
    <p> </p>
    </body>
    </html>
    and here is the form2mail.php:
    <?php
    # You can use this script to submit your forms or to receive orders by email.
    $MailToAddress = "[email protected]"; // your email address
    $redirectURL = "http://www.chucksmobile.com/thankyou.html"; // the URL of the thank you page.
    $MailSubject = "[Customer Contact Info]"; // the subject of the email
    $sendHTML = FALSE; //set to "false" to receive Plain TEXT e-mail
    $serverCheck = FALSE; // if, for some reason you can't send e-mails, set this to "false"
    # copyright 2006 Web4Future.com =================== READ THIS ===================================================
    # If you are asking for a name and an email address in your form, you can name the input fields "name" and "email".
    # If you do this, the message will apear to come from that email address and you can simply click the reply button to answer it.
    # To block an IP, simply add it to the blockip.txt text file.
    # CHMOD 777 the blockip.txt file (run "CHMOD 777 blockip.txt", without the double quotes)
    # This is needed because the script tries to block the IP that tried to hack it
    # If you have a multiple selection box or multiple checkboxes, you MUST name the multiple list box or checkbox as "name[]" instead of just "name"
    # you must also add "multiple" at the end of the tag like this: <select name="myselectname[]" multiple>
    # you have to do the same with checkboxes
    Web4Future Easiest Form2Mail (GPL).
    Copyright (C) 1998-2006 Web4Future.com All Rights Reserved.
    http://www.Web4Future.com/
    This script was written by George L. & Calin S. from Web4Future.com
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    # DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING ===================================================
    $w4fver =  "2.2";
    $ip = ($_SERVER['HTTP_X_FORWARDED_FOR'] == "" ? $_SERVER['REMOTE_ADDR'] : $_SERVER['HTTP_X_FORWARDED_FOR']);
    //function blockIP
    function blockip($ip) {
    $handle = @fopen("blockip.txt", 'a');
    @fwrite($handle, $ip."\n");
    @fclose($handle);
    $w4fx = stristr(file_get_contents('blockip.txt'),getenv('REMOTE_ADDR'));
    if ($serverCheck) {
    if (preg_match ("/".str_replace("www.", "", $_SERVER["SERVER_NAME"])."/i", $_SERVER["HTTP_REFERER"])) { $w4fy = TRUE; } else { $w4fy = FALSE; }
    } else { $w4fy = TRUE; }
    if (($w4fy === TRUE) && ($w4fx === FALSE)) {
    $w4fMessage = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html>\n<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head><body><font face=3Dverdana size=3D2>";
    if (count($_GET) >0) {
    reset($_GET);
    while(list($key, $val) = each($_GET)) {
      $GLOBALS[$key] = $val;
      if (is_array($val)) {
       $w4fMessage .= "<b>$key:</b> ";
       foreach ($val as $vala) {
        $vala =stripslashes($vala);
        $vala = htmlspecialchars($vala);
        if (trim($vala)) { if (stristr($vala,"Content-Type:") || stristr($vala,"MIME-Version") || stristr($vala,"Content-Transfer-Encoding") || stristr($vala,"bcc:")) { blockip($ip); die("ILLEGAL EXECUTION DETECTED!"); } }
        $w4fMessage .= "$vala, ";
       $w4fMessage .= "<br>\n";
      else {
       $val = stripslashes($val);
       if (trim($val)) { if (stristr($val,"Content-Type:") || stristr($val,"MIME-Version") || stristr($val,"Content-Transfer-Encoding") || stristr($val,"bcc:")) { blockip($ip); die("ILLEGAL EXECUTION DETECTED!"); } }
       if (($key == "Submit") || ($key == "submit")) { } 
       else {  if ($val == "") { $w4fMessage .= "$key: - <br>\n"; }
         else { $w4fMessage .= "<b>$key:</b> $val<br>\n"; }
    } // end while
    }//end if
    else {
    reset($_POST);
    while(list($key, $val) = each($_POST)) {
      $GLOBALS[$key] = $val;
      if (is_array($val)) {
       $w4fMessage .= "<b>$key:</b> ";
       foreach ($val as $vala) {
        $vala =stripslashes($vala);
        $vala = htmlspecialchars($vala);
        if (trim($vala)) { if (stristr($vala,"Content-Type:") || stristr($vala,"MIME-Version") || stristr($vala,"Content-Transfer-Encoding") || stristr($vala,"bcc:")) {blockip($ip); die("ILLEGAL EXECUTION DETECTED!"); } }   
        $w4fMessage .= "$vala, ";
       $w4fMessage .= "<br>\n";
      else {
       $val = stripslashes($val);
       if (trim($val)) { if (stristr($val,"Content-Type:") || stristr($val,"MIME-Version") || stristr($val,"Content-Transfer-Encoding") || stristr($val,"bcc:")) {blockip($ip); die("ILLEGAL EXECUTION DETECTED!"); } }
       if (($key == "Submit") || ($key == "submit")) { } 
       else {  if ($val == "") { $w4fMessage .= "$key: - <br>\n"; }
         else { $w4fMessage .= "<b>$key:</b> $val<br>\n"; }
    } // end while
    }//end else
    $w4fMessage .= "<font size=3D1><br><br>\n Sender IP: ".$ip."</font></font></body></html>";
        $w4f_what = array("/To:/i", "/Cc:/i", "/Bcc:/i","/Content-Type:/i","/\n/");
    $name = preg_replace($w4f_what, "", $name);
    $email = preg_replace($w4f_what, "", $email);
    if (!$email) {$email = $MailToAddress;}
    $mailHeader = "From: $name <$email>\r\n";
    $mailHeader .= "Reply-To: $name <$email>\r\n";
    $mailHeader .= "Message-ID: <". md5(rand()."".time()) ."@". ereg_replace("www.","",$_SERVER["SERVER_NAME"]) .">\r\n";
    $mailHeader .= "MIME-Version: 1.0\r\n";
    if ($sendHTML) {
      $mailHeader .= "Content-Type: multipart/alternative;";  
      $mailHeader .= "  boundary=\"----=_NextPart_000_000E_01C5256B.0AEFE730\"\r\n";    
    $mailHeader .= "X-Priority: 3\r\n";
    $mailHeader .= "X-Mailer: PHP/" . phpversion()."\r\n";
    $mailHeader .= "X-MimeOLE: Produced By Web4Future Easiest Form2Mail $w4fver\r\n";
    if ($sendHTML) {
      $mailMessage = "This is a multi-part message in MIME format.\r\n\r\n";
      $mailMessage .= "------=_NextPart_000_000E_01C5256B.0AEFE730\r\n";
      $mailMessage .= "Content-Type: text/plain;   charset=\"ISO-8859-1\"\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n";  
      $mailMessage .= trim(strip_tags($w4fMessage))."\r\n\r\n";  
      $mailMessage .= "------=_NextPart_000_000E_01C5256B.0AEFE730\r\n";  
      $mailMessage .= "Content-Type: text/html;   charset=\"ISO-8859-1\"\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n";  
      $mailMessage .= "$w4fMessage\r\n\r\n";  
      $mailMessage .= "------=_NextPart_000_000E_01C5256B.0AEFE730--\r\n";  
    if ($sendHTML === FALSE) {
      $mailHeader .= "Content-Type: text/plain;   charset=\"ISO-8859-1\"\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n";  
      $mailMessage .= trim(strip_tags($w4fMessage))."\r\n\r\n";  
    if (!mail($MailToAddress, $MailSubject, $mailMessage,$mailHeader)) { echo "Error sending e-mail!";}
    else { header("Location: ".$redirectURL); }
    } else { echo "<center><font face=verdana size=3 color=red><b>ILLEGAL EXECUTION DETECTED!</b></font></center>";}
    ?>
    Thanks in advance,
    Glenn
    [Subject line edited by moderator to indicate nature of request]

    Using PHP to process an online form and send the input by email is very simple. The mail() function takes a minimum of three arguments, namely: the address the mail is being sent to, the subject line, and the body of the email as a single string. The reason some people use scripts like form2mail.php is because they don't have the knowledge or patience to validate the user input to make sure it's safe to send.
    Rather than attempt to trawl through your complex form looking for the problems, I would suggest starting with a couple of simple tests.
    First of all, create a PHP page called mailtest.php containing the following script:
    <?php
    $to = '[email protected]'; // use your own email address
    $subject = 'PHP mail test';
    $message = 'This is a test of the mail() function.';
    $sent = mail($to, $subject, $message);
    if ($sent) {
      echo 'Mail was sent';
    } else {
      echo 'Problem sending mail';
    ?>
    Save the script, upload it to your server, and load it into a browser. If you see "Mail is sent", you're in business. If not, it probably means that the hosting company insists on the fifth argument being supplied to mail(). This is your email address preceded by -f. Change the line of code that sends the mail to this:
    $sent = mail($to, $subject, $message, null, '[email protected]');
    Obviously, replace "[email protected]" with your own email address.
    If this results in the mail being sent successfully, you will need to adapt the code in form2mail.php to accept the fifth parameter. You need to change the following line, which is a few lines from the end of the script:
    if (!mail($MailToAddress, $MailSubject, $mailMessage,$mailHeader))
    Change it to this:
    if (!mail($MailToAddress, $MailSubject, $mailMessage,$mailHeader, '[email protected]'))
    Again, use your own email address instead of "[email protected]".
    Once you have determined whether you need the fifth argument, test form2mail.php with a very simple form like this:
    <form id="form1" name="form1" method="post" action="form2mail.php">
      <p>
        <label for="name">Name:</label>
        <input type="text" name="name" id="name" />
      </p>
      <p>
        <label for="email">Email:</label>
        <input type="text" name="email" id="email" />
      </p>
      <p>
        <label>
          <input type="checkbox" name="options[]" value="boat cleaning" id="options_0" />
          Boat cleaning</label>
        <br />
        <label>
          <input type="checkbox" name="options[]" value="RV cleaning" id="options_1" />
          RV cleaning</label>
        <br />
        <label>
          <input type="checkbox" name="options[]" value="motorcycle cleaning" id="options_2" />
          Motorcycle cleaning</label>
      </p>
      <p>
        <input type="submit" name="send" id="send" value="Submit" />
      </p>
    </form>
    If that works, you can start to make the form more complex and add back your JavaScript validation.

Maybe you are looking for

  • Properties & tools are greyed out

    Hi, Whenever I open a new document in Flash CS5 Pro, the properties & tools panels are greyed out. Does anyone know how to fix this? Thanks in advance. pjirles

  • Regarding doc type RK (  invoice correction request)

    hi When i am creating invoice correction request, the line item( item category G2N) in display mode only. But another line item( item category L2N) is in enable mode. How can i make line item of category G2N enable. veru urgent please. Regards, ram

  • [SOLVED] Troubleshooting kernel panics since 3.4

    All kernel versions since 3.4 have been absolutely unstable on my machine. A panic might happen right during bootup, or if it boots up, there will be random segfaults all over the place, followed by a panic no later than 20 minutes or so from bootup.

  • My imac os 10.7.5 will not shut down- it just goes to sleep

    when i go apple/shut down i get the box asking me if i want to shut down. i click shut down, and it goes through the ordinary routine- one thing at a time, grey screen- fade to black. next day tho, i just touch it and it's back, exactly as if it had

  • Cannot update time machine using hd

    Won't let me update OS X Mavericks says Time Machine is using HD.