Results 1 to 5 of 5
  1. #1
    Full Member Larry's Avatar
    Join Date
    January 18th, 2005
    Posts
    344
    I'm trying to hack a php formmail and need a little help.

    the form is here:

    http://nextoyota.com/charlotte-toyota-dealers.htm


    and the part of the code for the form return is here:


    $name = $_POST['name'] ;
    $model = $_POST['model'] ;
    $trim = $_POST['trim'] ;
    $comments = $_POST['comments'] ;
    $new = $_POST['new'] ;
    $used = $_POST['used'] ;
    $tradeyes = $_POST['tradeyes'] ;
    $tradeno = $_POST['tradeno'] ;
    $phone = $_POST['phone'] ;
    $email = $_POST['email'] ;
    $http_referrer = getenv( "HTTP_REFERER" );

    if (!isset($_POST['email'])) {
    header( "Location: $formurl" );
    exit ;
    }
    if (empty($name) || empty($email) || empty($comments)) {
    header( "Location: $errorurl" );
    exit ;
    }

    $messageproper =

    "This message was sent from:\n" .
    "$http_referrer\n" .
    "------------------------- COMMENTS -------------------------\n\n" .
    $comments .
    "\n\n------------------------------------------------------------\n" ;

    mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>\nReply-To: \"$name\" <$email>\nX-Mailer: chfeedback.php 2.01" );
    header( "Location: $thankyouurl" );
    exit ;

    ?>



    all seems to be working well except the form only returns what is in the comments section...no name..no vehicle..etc.

    can one of you gurus help me out?

    thanks,

    larry

  2. #2
    Member Speedy's Avatar
    Join Date
    January 18th, 2005
    Location
    Lancashire UK
    Posts
    165
    Hi Larry,
    Try the code below and dont forget to add your email address and the email subject.
    Any probs PM me.

    Steve

    ------------------------------

    <?php
    if (!isset($_POST['email'])) {
    header( "Location: $formurl" );
    exit() ;
    }
    if (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['comments'])) {
    header( "Location: $errorurl" );
    exit() ;
    }
    $mailto = ""; // Your Email Address
    $subject = ""; // Message Subject
    $messageproper = "
    Name: ".$_POST['name']."
    Model: ".$_POST['model']."
    Trim: ".$_POST['trim']."
    Comments: ".$_POST['comments']."
    New: ".$_POST['new']."
    Used: ".$_POST['used']."
    Tradeyes: ".$_POST['tradeyes']."
    Tradeno: ".$_POST['tradeno']."
    Phone: ".$_POST['phone']."
    Email: ".$_POST['email']."
    _______________________________________________
    End of Email
    " ;
    ## Strip out the bad and unwanted charactors ( " ' / \ < > ) etc. that have appeared
    $subject = stripslashes($subject);
    $messageproper = stripslashes($messageproper);
    ## Send the email
    @mail($mailto, $yoursubject, $messageproper, "From: ".$_POST['email']."");
    header( "Location: $thankyouurl" );
    exit() ;
    ?>
    --------------------------------------------------
    Life at the top is hard,
    But life at the bottom is harder ....

  3. #3
    Full Member Larry's Avatar
    Join Date
    January 18th, 2005
    Posts
    344
    Thanks Steve! It works perfectly with one exception...the subject line is blank when the email arrives..but quite frankly this is for my personal use so it is not important. Everything else is working perfectly.

    I appreciate you taking the time to fix that.

  4. #4
    Full Member
    Join Date
    January 18th, 2005
    Posts
    379
    Simply change the line that says:
    $subject = ""; // Message Subject

    to

    $subject = "Charlotte Toyota Dealers Question";

    YOu could also put the subject in the form with a hidden tag
    <input type="hidden" name="subject" value="Charlotte Toyota Dealers Question">

    and then in the php code change
    $subject = ""; // Message Subject

    to
    $subject= $_POST['subject'];

  5. #5
    Member Speedy's Avatar
    Join Date
    January 18th, 2005
    Location
    Lancashire UK
    Posts
    165
    Hi Larry,
    Your welcome, glad it worked.
    I dont mind helping anyone out as long as they have had an attempt themselves. If you do what MrSpeed said it will work fine.

    Its the ones who ask for a solution without even attempting to have a go themselves that get on my nerves!

    Cheers
    Steve
    --------------------------------------------------
    Life at the top is hard,
    But life at the bottom is harder ....

  6. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. PHP question - include(file.php) with variables
    By teezone in forum Programming / Datafeeds / Tools
    Replies: 8
    Last Post: September 4th, 2009, 04:54 PM

Posting Permissions

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