Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16
  1. #1
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    I need serious help with this php mail form here is the code...
    Code:
    <?php 
    $mailto = "mindyourownbusinessplease@whatever.com";
    $subject = $_POST['Subject'];
    $redirect = "contactdone.php";
    
    $getcomments = $_POST['Comments'];
    $getfrom = $_POST['Name'];
    $getemail = $_POST['Email'];
    $getcompany = $_POST['Company'];
    $gettelephone = $_POST['Telephone'];
    
    $from = "From: $getfrom";
    $email = "Reply To: $getemail";
    $company = "Company: $getcompany";
    $telephone = "Telephone: $gettelephone";
    
    $footer = "$from\n$email\n$company\n$telephone";
    $message = "$getcomments\n\n------------------\n$footer";
    
    
    if (mail($mailto, $subject, $message)) {
      
      header("Location: $redirect");
    } else {
      echo('The form failed to e-mail, please click here');
    }
    ?>
    this looks like this in the e-mail with all fields filled in
    This

    Is

    A

    Test

    ------------------
    From:
    Reply To: whatever@whatever.com
    Company:
    Telephone:
    That is god damn frustrating, what is wrong there?

    This error is stopping me get my site finished, so help would be very appreciated

    Thanks
    JR

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Are you sure the form is POSTing the data and not GETting it?
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    yes, it is posting
    Code:
    <form name="quickcontact" method="post" action="QCSend.php">
    JR

  5. #4
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    PHP gives me a headache ,

    i have been trying to sort this for ages and no luck, it is going to take me years

    any ideas anybody, sorry for bumping the post but i am getting realled p'd off :angry:
    JR

  6. #5
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    The array keys are case-sensitive (variables aren't, IIRC). Make sure they're in that format. I just use lowercase all the time to avoid problems.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  7. #6
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    right i will put everything in lowercase and report back, thanks
    JR

  8. #7
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    yes it worked thanks a lot, now i have the problem of making sure fields are filled in.

    I noticed in your script you used if then isset, but i have more than 1 field that needs filling in + i want to make sure the e-mail address that the user puts in is valid (in the format whatever@whatever.whatever, not checking if the e-mail address exists, although that would be good if it was easy to code )
    JR

  9. #8
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    You should probably use:
    PHP Code:
    if (empty(trim($_POST['whatever']))) 
    ...actually.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  10. #9
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    what is the whole code for that, i am very unfamiliar with php sorry would it be ....

    PHP Code:
    if (empty(trim($_POST['whatever']))) {

    header("Location: $redirect");
    } else {
      echo(
    'Please fill in all fields marked in blue, please click here');

    also could i store the multiple fields that need filling in in one variable and have it like this?
    PHP Code:
    if (empty(trim($requiredwhatever))) 
    how would that work? thanks for your help Mr. PHP
    JR

  11. #10
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Here's a crude example (actually I use this in my mail script ):
    PHP Code:
        // any fields empty?
        
    $required = array("to""message");
        foreach (
    $required as $value)
        {
            if (empty(
    trim($_POST[$value])))
            {
                echo 
    "you left a field empty!";
                exit;
            }
        } 
    Just populate $required with the keys that have to be filled in.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:43 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com