Error- Contact Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kammaldeep
    New Member
    • Feb 2007
    • 1

    Error- Contact Form

    hi,

    i m newbie 2 PHP & to b frank ... will alwaz be ... i dont think i will go into much details with PHP as my work doesnot include workin with PHP

    bt i have a forum .. and i want to make a personal contact page in it .... and save all details in my new database....

    i have website in the root folder


    i get dis error

    Parse error: parse error, unexpected T_VARIABLE in C:\wamp\www\huk umnama\contact. php on line 120

    Error on saving to database & also in mailing


    <html>
    <head>
    </head>
    <body>

    <?php
    /* grabs the POST variables and puts them into variables that we can use */
    $firstName=$_PO ST['firstName'];
    $lastName=$_POS T['lastName'];
    $company=$_POST['company'];
    $email=$_POST['email'];
    $website=$_POST['website'];
    $countryCode=$_ POST['countryCode'];
    $phone=$_POST['phone'];
    $phoneExt=$_POS T['phoneExt'];
    $mobile=$_POST['mobile'];
    $fax=$_POST['fax'];
    $address=$_POST['address'];
    $city=$_POST['city'];
    $state=$_POST['state'];
    $country=$_POST['country'];
    $zipCode=$_POST['zipCode'];
    $heardAbout=$_P OST['heardAbout'];
    $inquiring=$_PO ST['inquiring'];

    //---------VALIDATION-------->
    if($firstName){//----> CHECK input
    }
    else{
    $error.="Please , go back and fill out your first name<br>\n";//----> ERROR if no input
    }

    if($lastName){//----> CHECK input
    }
    else{
    $error.="Please , go back and fill out your last name<br>\n";//----> ERROR if no input
    }

    if($email){//----> CHECK input
    }
    else{
    $error.="Please , go back and fill out your e-mail address<br>\n";//----> ERROR if no input
    }

    if($phone){//----> CHECK input
    }
    else{
    $error.="Please , go back and fill out your phone number<br>\n";//----> ERROR if no input
    }

    if($address){//----> CHECK input
    }
    else{
    $error.="Please , go back and fill out your mailing address<br>\n";//----> ERROR if no input
    }

    if($city){//----> CHECK input
    }
    else{
    $error.="Please , go back and fill out your city name<br>\n";//----> ERROR if no input
    }

    if($zipCode){//----> CHECK input
    }
    else{
    $error.="Please , go back and fill out your zip code<br>\n";//----> ERROR if no input
    }
    //-------->ERROR FREE??
    if($error==""){
    echo "Thank you for inquiring about us! A receipt of your submission will be e-mailed to you almost immediately.";
    //----------------------------------
    $mailContent="--------CONTACT--------\n"
    ."First Name: ".$firstName."\ n"
    ."Last Name: ".$lastName."\n "
    ."Company: ".$company. "\n"
    ."E-mail: ".$email."\ n"
    ."Website: ".$website."\n\ n--------PHONE--------\n"
    ."Phone: ".$countryCode. " ".$phone."\ n"
    ."Extension: ".$phoneExt."\n "
    ."Fax: ".$fax."\n"
    ."Mobile: ".$mobile." \n\n--------ADDRESS--------\n"
    ."Street Address: ".$address. "\n"
    ."City: ".$city."\n "
    ."State: ".$state."\ n"
    ."Country: ".$country. "\n"
    ."Zip Code: ".$zipCode."\n\ n--------INFO--------\n"
    ."Where did you hear about us? ".$heardAbout." \n"
    ."Inquiring About: ".$inquiring."\ n"
    //----------------------------------
    $toAddress="mai l2me@mailme.com "; /* change this! */
    $subject="MyWeb Site.com's Products"; /* change this! */
    $recipientSubje ct="MyWebSite.c om's Contact Form"; /* change this! */
    $receiptMessage = "Thank you ".$firstNam e." for inquiring about MyWebSite.com's Products!\n\n\n Here is what you submitted to us:\n\n"
    // ."--------CONTACT--------\n"
    ."First Name: ".$firstName."\ n"
    ."Last Name: ".$lastName."\n "
    ."Company: ".$company. "\n"
    ."E-mail: ".$email."\ n"
    ."Website: ".$website."\n\ n--------PHONE--------\n"
    ."Phone: ".$countryCode. " ".$phone."\ n"
    ."Extension: ".$phoneExt."\n "
    ."Fax: ".$fax."\n"
    ."Mobile: ".$mobile." \n\n--------ADDRESS--------\n"
    ."Street Address: ".$address. "\n"
    ."City: ".$city."\n "
    ."State: ".$state."\ n"
    ."Country: ".$country. "\n"
    ."Zip Code: ".$zipCode."\n\ n--------INFO--------\n"
    ."Where did you hear about us? ".$heardAbout." \n"
    ."Inquiring About: ".$inquiring."\ n"
    //----------------------------------
    mail($email, $subject, $receiptMessage ,"From:$toAddre ss");
    //----------------------------------
    mail($toAddress ,$recipientSubj ect,$mailConten t,"From:$email" );
    --->echo $mailContent;

    //////////////////////////////////////// CONNECT TO MYSQL DB ////////////////////
    // OPEN CONNECTION --->
    $connection=mys ql_connect("loc alhost","root", "") or die("Unable to connect!"); /* change this! */

    mysql_select_db ("hukumnama_con tact") or die("Unable to select database!"); /* change this! */

    // EXECUTE QUERY --->
    $query="INSERT INTO generalContact (
    firstName,
    lastName,
    company,
    email,
    website,
    countryCode,
    phone,
    phoneExt,
    mobile,
    fax,
    address,
    city,
    state,
    country,
    zipCode,
    heardAbout,
    inquiringOn)
    VALUES(
    '".$firstName." ',
    '".$lastName."' ,
    '".$company. "',
    '".$email."' ,
    '".$website. "',
    '".$countryCode ."',
    '".$phone."' ,
    '".$phoneExt."' ,
    '".$mobile." ',
    '".$fax."',
    '".$address. "',
    '".$city."',
    '".$state."' ,
    '".$country. "',
    '".$zipCode. "',
    '".$heardAbout. "',
    '".$inquiring." ')";
    //////----->
    $result=mysql_q uery($query) or die("Error in query:".mysql_e rror());
    //if ($result)
    //echo mysql_affected_ rows()." row inserted into the database effectively.";

    // CLOSE CONNECTION --->
    mysql_close($co nnection);

    ///////////////////////////////////////////////////////////////////////////////////
    }
    else{

    print "Sorry, but the form cannot be sent until the fields indicated are filled out completely - <br>\n";
    print "$error<br> \n";
    print "<br>\n";
    print "<br>\n";
    print "Please use your \"Back\" button to return to the form to correct the omissions. Thank you.<br>\n";
    }

    ?>
    </body>
    </html>


    can anyone help me out ......


    thnks .....
Working...