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

    help in php sendemail

    hi! I am totally new in php world please help me!!thanks advance
    I am facing parse errorarse error, unexpected T_VARIABLE in line 75
    Here is the code for my html form

    <html>
    <head>
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 1</title>
    <style>
    <!--
    div.Section1
    {page:Section1;}
    -->
    </style>
    </head>

    <body>

    <form name="phpformmailer" method="POST" align="center" action="process11.php">
    <table class="MsoNormalTable" style="width: 375pt" cellSpacing="0" cellPadding="0" width="500" border="0">
    <tr style="height: 15.75pt">
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in; HEIGHT: 15.75pt">
    <p align="center"><b><font color="#6B9C6B" face="Arial Black">The * fields are
    required for completing registration</font></b></p>
    <p>&nbsp;</td>
    </tr>
    <tr style="height: 384pt">
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in; HEIGHT: 384pt">
    <table class="MsoNormalTable" style="width: 375pt; border-collapse: collapse" cellSpacing="0" cellPadding="0" width="500" border="0" name="inner_table">
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; WIDTH: 187.5pt; PADDING-TOP: 0in" width="250">
    <p class="MsoNormal" style="TEXT-ALIGN: right" align="right"><b>
    <span style="font-size: 10pt; font-family: Verdana">Title : </span>
    </b></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; WIDTH: 187.5pt; PADDING-TOP: 0in" width="250">
    <p class="MsoNormal"><b><select name="title">
    <option selected>Mr.</option>
    <option>Mrs.</option>
    <option>Ms.</option>
    <option>Miss</option>
    <option>Dr.</option>
    <option>Prof.</option>
    </select></b></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal" style="TEXT-ALIGN: right" align="right"><b>
    <span style="font-size: 10pt; font-family: Verdana">*Surname : </span>
    </b></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal"><b><input size="21" name="sname"></b></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal" style="TEXT-ALIGN: right" align="right"><b>
    <span style="font-size: 10pt; font-family: Verdana">Given Name :
    </span></b></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal"><b><input size="37" name="name"></b></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal" style="TEXT-ALIGN: right" align="right"><b>
    <span style="font-size: 10pt; font-family: Verdana">*Job Title/Position
    : </span></b></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal"><b><input size="40" name="job"></b></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal" style="TEXT-ALIGN: right" align="right"><strong>
    <span style="font-size: 10pt; font-family: Verdana">Institution /
    Organization</span></strong><b><span style="font-size: 10pt; font-family: Verdana">
    : </span></b></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal"><b><input size="40" name="org"></b></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal" style="TEXT-ALIGN: right" align="right"><b>
    <span style="font-size: 10pt; font-family: Verdana">*Address : </span>
    </b></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal"><b><input size="40" name="address"></b></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal" style="TEXT-ALIGN: right" align="right"><b>
    <span style="font-size: 10pt; font-family: Verdana">State/Province :
    </span></b></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal"><b><input size="34" name="state"></b></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal" style="TEXT-ALIGN: right" align="right"><b>
    <span style="font-size: 10pt; font-family: Verdana">*Country : </span>
    </b></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal"><b><input size="34" name="country"></b></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal" style="TEXT-ALIGN: right" align="right"><b>
    <span style="font-size: 10pt; font-family: Verdana">*Postal/Zip Code :
    </span></b></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal"><b><input size="15" name="zip"></b></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal" style="TEXT-ALIGN: right" align="right"><b>
    <span style="font-size: 10pt; font-family: Verdana">Phone : </span>
    </b></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal"><b><input size="37" name="phone"></b></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal" style="TEXT-ALIGN: right" align="right"><b>
    <span style="font-size: 10pt; font-family: Verdana">Extension : </span>
    </b></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal"><b><input size="11" name="ex"></b></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal" style="TEXT-ALIGN: right" align="right"><b>
    <span style="font-size: 10pt; font-family: Verdana">Fax : </span></b>
    </td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal"><b><input size="37" name="fax"></b></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal" style="TEXT-ALIGN: right" align="right"><b>
    <span style="font-size: 10pt; font-family: Verdana">*E-Mail : </span>
    </b></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal"><b><input size="37" name="email"></b></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal" style="TEXT-ALIGN: right" align="right"><strong>
    <span style="font-size: 10pt; font-family: Verdana">*Passport Number:</span></strong></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal"><b><input size="37" name="passport_no"></b></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal" style="TEXT-ALIGN: right" align="right"><strong>
    <span style="font-size: 10pt; font-family: Verdana">Valid Until:</span></strong></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal"><b><input size="19" name="valid_until"></b></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p style="TEXT-ALIGN: right" align="right"><b>
    <span style="font-size: 10pt; font-family: Verdana">Subject :</span></b></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; WIDTH: 221.25pt; PADDING-TOP: 0in" width="295">
    <p class="MsoNormal"><b><input size="40" name="subject"></b></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in" vAlign="top">
    <p style="TEXT-ALIGN: right" align="right"><b>
    <span style="font-size: 10pt; font-family: Verdana">Mode of
    presentation :</span></b></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; WIDTH: 221.25pt; PADDING-TOP: 0in" width="295">
    <p class="MsoNormal"><b></p>
    <span style="font-size: 10pt; font-family: Verdana">
    <fieldset style="BORDER-RIGHT: #0000ff 1px ridge; PADDING-RIGHT: 2px; BORDER-TOP: #0000ff 1px ridge; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; BORDER-LEFT: #0000ff 1px ridge; PADDING-TOP: 2px; BORDER-BOTTOM: #0000ff 1px ridge">
    <legend>Equipments </legend>
    </span></b>&nbsp;<p style="MARGIN: 0in 0in 0pt">
    <span style="color: blue; font-family: Verdana; font-weight: 700">
    <input type="checkbox" value="Over Head Projector" name="c1" Projector Head></span><b><span style="font-size: 10pt; font-family: Verdana">Over
    Head Projector</span></b><span style="font-family: Verdana; font-weight: 700">
    </span></p>
    <p style="MARGIN: 0in 0in 0pt"><b>
    <span style="COLOR: blue; FONT-FAMILY: Verdana">
    <input type="checkbox" value="Slide Projector" name="c2" Projector></span><span style="font-size: 10pt; font-family: Verdana">Slide
    Projector</span></b></p>
    <p style="MARGIN: 0in 0in 0pt"><b>
    <span style="COLOR: blue; FONT-FAMILY: Verdana">
    <input type="checkbox" value="Multimedia Projector" name="c3" Projector></span><span style="font-size: 10pt; font-family: Verdana">Multimedia
    Projector</span></b></p>
    <p style="MARGIN: 0in 0in 0pt">
    <span style="font-family: Verdana; font-weight: 700">
    <input type="checkbox" name="c4" VCR value="ON"></span><b><span style="font-size: 10pt; font-family: Verdana">TV
    &amp; VCR</span></b></p>
    <p style="MARGIN: 0in 0in 0pt">
    <span style="color: blue; font-family: Verdana; font-weight: 700">
    <input type="checkbox" value="Others" name="c5"></span><b><span style="font-size: 10pt; font-family: Verdana">Others
    (Mention below)</span></b></p>
    </fieldset></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p style="TEXT-ALIGN: right" align="right"><b>
    <span style="font-size: 10pt; font-family: Verdana">Comments (If any)
    :</span></b></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; WIDTH: 221.25pt; PADDING-TOP: 0in" width="295">
    <p class="MsoNormal"><span style="color: blue; font-weight: 700">
    <input size="41" name="comments"></span></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal"><b>&nbsp;</b></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal"><b>&nbsp;</b></td>
    </tr>
    <tr>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal" style="TEXT-ALIGN: right" align="right">
    <span style="font-family: Verdana; font-weight: 700"><script language="JavaScript"><!--
    function validateForm()
    {
    var okSoFar=true
    with (document.phpformmailer)
    {
    var foundAt = email.value.indexOf("@",0)
    if (foundAt < 1 && okSoFar)
    {
    okSoFar = false
    alert ("Please enter a valid email address.")
    email.focus()
    }
    if (sname.value=="" && okSoFar)
    {
    okSoFar=false
    alert("Please enter the surname.")
    sname.focus()
    }
    if (job.value=="" && okSoFar)
    {
    okSoFar=false
    alert("Please enter information about your job")
    job.focus()
    }
    if (address.value=="" && okSoFar)
    {
    okSoFar=false
    alert("Please enter address.")
    address.focus()
    }if (country.value=="" && okSoFar)
    {
    okSoFar=false
    alert("Please enter the country.")
    country.focus()
    }
    if (zip.value=="" && okSoFar)
    {
    okSoFar=false
    alert("Please enter zipcode.")
    zip.focus()
    }
    if (passport_no.value=="" && okSoFar)
    {
    okSoFar=false
    alert("Please enter passport number.")
    passport_no.focus()
    }
    if (okSoFar==true) submit();
    }
    }
    // --></script>
    <input type="reset" value="Reset" name="Reset"></span></td>
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in">
    <p class="MsoNormal"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="submit" value="Submit Query" name="Submit2" ONCLICK="javascript:validateForm()" METHOD="post" ACTION="process11.php"></b></td>
    </tr>
    </table>
    </td>
    </tr>
    <tr style="height: 14.25pt">
    <td style="PADDING-RIGHT: 0in; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; PADDING-TOP: 0in; HEIGHT: 14.25pt">
    <p class="MsoNormal"><b>&nbsp;</b></td>
    </tr>
    </table>
    </form>

    </body>

    </html>



    and the php code is

    <?php

    // ------- three variables you MUST change below -------------------------------------------------------
    $valid_ref1="http://mydomain.com/form.htm";// chamge "Your--domain" to your domain
    $valid_ref2="http://www.mydomain.com/form.htm";// chamge "Your--domain" to your domain
    $replyemail="mydomain@yahoo.com";//change to your email address
    // ------------------------------------------------------------

    //clean input in case of header injection attempts!
    function clean_input_4email($value, $check_all_patterns = true)
    {
    $patterns[0] = '/content-type:/';
    $patterns[1] = '/to:/';
    $patterns[2] = '/cc:/';
    $patterns[3] = '/bcc:/';
    if ($check_all_patterns)
    {
    $patterns[4] = '/\r/';
    $patterns[5] = '/\n/';
    $patterns[6] = '/%0a/';
    $patterns[7] = '/%0d/';
    }
    //NOTE: can use str_ireplace as this is case insensitive but only available on PHP version 5.0.
    return preg_replace($patterns, "", strtolower($value));
    }

    $title = clean_input_4email($_POST["title"]);
    $sname = clean_input_4email($_POST["sname"]);
    $name = clean_input_4email($_POST["name"]);
    $job = clean_input_4email($_POST["job"]);
    $org = clean_input_4email($_POST["org"]);
    $address = clean_input_4email($_POST["address"]);
    $state = clean_input_4email($_POST["state"]);
    $country = clean_input_4email($_POST["country"]);
    $zip = clean_input_4email($_POST["zip"]);
    $phone = clean_input_4email($_POST["phone"]);
    $ex = clean_input_4email($_POST["ex"]);
    $fax = clean_input_4email($_POST["fax"]);
    $email = clean_input_4email($_POST["email"]);
    $passport_no = clean_input_4email($_POST["passport_no"]);
    $valid_until = clean_input_4email($_POST["valid_until"]);
    $subject = clean_input_4email($_POST["subject"]);
    $c1 = clean_input_4email($_POST["c1"]);
    $c2 = clean_input_4email($_POST["c2"]);
    $c3 = clean_input_4email($_POST["c3"]);
    $c4 = clean_input_4email($_POST["c4"]);
    $c5 = clean_input_4email($_POST["c5"]);
    $comments = clean_input_4email($_POST["comments"], false);

    $error_msg='ERROR - not sent. Try again.';

    $success_sent_msg='<p align="center"><strong>&nbsp;</strong></p>
    <p align="center"><strong>Your message has been successfully sent to us<br>
    </strong> and we will reply as soon as possible.</p>
    <p align="center">A copy of your query has been sent to you.</p>
    <p align="center">Thank you for contacting us.</p>';

    $replymessage = "Hi $title $sname $name

    Thank you for your email.

    We will endeavour to reply to you shortly.

    Please DO NOT reply to this email.

    Below is a copy of the message you submitted:
    --------------------------------------------------
    job: $job
    Organization:$org
    Subject: $subject
    comments:$comments
    --------------------------------------------------

    Thank you";

    // email variable not set - load $valid_ref1 page
    if (!isset($_POST['email']))
    {
    echo "<script language=\"JavaScript\"><!--\n ";
    echo "top.location.href = \"$valid_ref1\"; \n// --></script>";
    exit;
    }

    $ref_page=$_SERVER["HTTP_REFERER"];
    $valid_referrer=0;
    if($ref_page==$valid_ref1) $valid_referrer=1;
    elseif($ref_page==$valid_ref2) $valid_referrer=1;
    if(!$valid_referrer)
    {
    echo "<script language=\"JavaScript\"><!--\n alert(\"$error_msg\");\n";
    echo "top.location.href = \"$valid_ref1\"; \n// --></script>";
    exit;
    }

    if ($c1 == "y") {
    $req1 = "Overhead projector \n" ;
    }
    if ($c2 == "y") {
    $req2 = "Slide projector \n";
    }
    if ($c3 == "y") {
    $req3 = "Multiledia projector \n";
    }
    if ($c4 == "y") {
    $req4 = "TV, VCR \n";
    }
    if ($c5 == "y") {
    $req5 = "Other \n";
    }
    $req = $req1 . $req2 . $req3 . $req4 . $req5;

    $formcontent = "title: $title \nsname: $sname \nname: $name \njob: $job \norganization: $org \naddress: $address \nstate: $state \ncountry: $country \nZip: $zip \nphone: $phone \nextension: $ex \nfax: $fax \npassport: $passport_no \nvalid_until: $valid_until \nrequired: $req \nsubject: $subject \ncomments:$comments;
    mail("$replyemail",
    "$subject",
    "$formcontent",
    "From: $email\nReply-To: $email");
    mail("$email",
    "Receipt: $subject",
    "$replymessage",
    "From: $replyemail\nReply-To: $replyemail");
    echo $success_sent_msg;
    ?>

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    there is a missing closing " (quote) here ..

    PHP Code:
    <?
    $formcontent 
    "title: $title \nsname: $sname \nname: $name \njob: $job \norganization: $org \naddress: $address \nstate: $state \ncountry: $country \nZip: $zip \nphone: $phone \nextension: $ex \nfax: $fax \npassport: $passport_no \nvalid_until: $valid_until \nrequired: $req \nsubject: $subject \ncomments:$comments; //<<here
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

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