Jump to content

simon71

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Posts posted by simon71

  1. code now reads:

    <?php
    if(isset($_POST['Submit'])) {
        $email_to =      "form@iter-research.co.uk";
        $name =          $_POST["Name"];
        $email_from =    $_POST["form@iter-research.co.uk"];
        $message =       $_POST["Name"] . $_POST["Address"] . $_POST["Postcode"] . $_POST["Email"] . $_POST["Gender"] . $_POST["Age"] . $_POST["Correspondence"];
        $email_subject = "Consultation Form";
        $headers =       "FROM: $email_from.\n" . "reply-to:$email_from.\n";
    
        $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*"."@[a-z0-9-]+(\.[a-z0-9-]{1,})*"."\.([a-z]{2,}){1}$";
    if (!eregi($regex,($email_from))) {
           die("The email address entered is invalid.");
    } else {
           $message = "Name: ". $name . "\r\nMessage: " . $message;
    
           ini_set("sendmail_from", $email_from);
    
           $sent = mail($email_to, $email_subject, $message, $headers);
    
           if(isset($sent)) {
              header("Location: http://www.iter-rese...hank_you.html/");
           } else {
              echo "There has been an error sending your message. Please try later.";
           }
       }
    } else {
        echo 'You never clicked the submit button!';
    }
    ?>

     

    still get email address is invalid

  2. The form Script is:

     

    <form action="/htdocs/form/sendmail.php" method="post" name="form1" target="_blank" id="form1">
            <table width="100%" border="0" cellspacing="0" cellpadding="3">
            <tr>
            <td width="38%"><label>
            <div align="right">Name</div>
            </label></td>
            <td width="62%"><input name="Name" type="text" id="Name" tabindex="1" size="50" /></td>
            </tr>
            <tr>
            <td><label>
            <div align="right">Address</div>
            </label></td>
            <td><textarea name="Address" cols="50" id="Address" tabindex="2"></textarea></td>
            </tr>
            <tr>
            <td><label>
            <div align="right">Postcode</div>
            </label></td>
            <td><input name="Postcode" type="text" id="Postcode" tabindex="3" /></td>
            </tr>
            <tr>
            <td><label>
            <div align="right">Email</div>
            </label></td>
            <td><input name="Email" type="text" id="Email" tabindex="4" size="50" /></td>
            </tr>
            <tr>
            <td><label>
            <div align="right">Gender</div>
            </label></td>
            <td><select name="Gender" size="1" id="Gender" tabindex="5">
            <option value="1">Male</option>
            <option value="2">Female</option>
            <option value="0" selected="selected">Please Select</option>
            </select></td>
            </tr>
            <tr>
            <td><label>
            <div align="right">Age</div>
            </label></td>
            <td><select name="Age" size="1" id="Age">
            <option value="0">Please Select</option>
            <option value="1"><16</option>
            <option value="2">17-20</option>
            <option value="3">21-25</option>
            <option value="4">26-30</option>
            <option value="5">31-35</option>
            <option value="6">36-40</option>
            <option value="7">41-45</option>
            <option value="8">46-50</option>
            <option value="9">50></option>
            </select></td>
            </tr>
            <tr>
            <td><label>
            <div align="right">Would you prefer any further correspondence to be in Welsh Or English </div>
            </label></td>
            <td><select name="Correspondence" size="1" id="Correspondence">
            <option value="0">Please Select</option>
            <option value="1">Welsh</option>
            <option value="2">English</option>
            </select>
            <label>
            <input type="submit" name="Submit" value="Submit" />
            <input name="Reset" type="reset" id="Reset" value="Reset" />
            </label></td>
            </tr>
            </table>
        </form>

     

  3. Hi,

     

    Im new to PHP and contact forms so need some help getting my data collection form to work.

     

    Im hosting on Fasthost. My form action is '/htdocs/form/sendmail.php'.

     

    my script is:

     

    <?php
    $email_to="form@iter-research.co.uk";
    $name=$_POST["Name"];
    $email_from=$_POST["form@iter-research.co.uk"];
    $message=$_POST["Name,Address,Postcode,Email,Gender,Age,Correspondence"];
    $email_subject="Consultation Form";
    $headers=
    "from:$email_from.\n";
    "reply-to:$email_from.\n";
    
    if(!filter_var($email_from, FILTER_VALIDATE_EMAIL)) {
    die("The email address entered is invalid.");
    $message = "Name: ". $name . "\r\nMessage: " . $message;
    ini_set("sendmail_from", $email_from);
    $sent = mail($email_to, $email_subject, $message, $headers, -f$email_from);
    if($sent) {
    header("Location: http://www.iter-rese...hank_you.html/");
    
    } else {
    echo "There has been an error sending your message. Please try later.";
    }
    }
    ?>

     

    When i hit the submit button the browser just trys to open a new window with my PHP script in.

     

    I'm New to PHP and contact forms so if im doing something really basic and stupid i apologise in advance.

     

    has anyone got any suggestion??

     

    Simon

×
×
  • 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.