Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2006
    Location
    NY
    Posts
    485

    PHP Email Script Help

    I have this php script, and i set it so the email that is entered in the contact form, is the email that it is sentfrom when it is recieved in the inbox.

    I set it as
    PHP Code:
    $EmailFrom "".$Email.""
    For some reason, it doesnt display the email sent from when i receive the email.

    If i were to replace the
    PHP Code:
    $EmailFrom "".$Email.""
    with a actual email like
    PHP Code:
    $EmailFrom "email@email.com"
    It would work... How can i make it so, it shows the email it is sent from, in the email someone enters in the contact form.


    The script is below.


    PHP Code:
       <div id="contactform">
                    <
    form method="post" action="contactengine.php">
                      
    NAME: &nbsp;
                      <
    input type="text" name="Name" id="Name" size="50" maxlength="18" />
                      <
    br />
                      
    EMAIL:&nbsp;
                      <
    input type="text" name="Email" id="Email" size="50" maxlength="18" />
                      <
    br />
                      
    Message:
                      <
    textarea name="Message" id="Message" cols="30" rows="3" maxlength="240" ></textarea>
                      <
    input type="Submit" name="submit" value="Submit" />
                    </
    form>
                  </
    div


    PHP Code:
    <?php

    $EmailFrom 
    "".$Email."";
    $EmailTo "email@email.com";
    $Subject "You have been contacted";
    $Name Trim(stripslashes($_POST['Name'])); 
    $Email Trim(stripslashes($_POST['Email'])); 
    $Message Trim(stripslashes($_POST['Message'])); 

    // validation
    $validationOK=true;
    if (!
    $validationOK) {
      print 
    "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
      exit;
    }

    // prepare email body text
    $Body "";
    $Body .= "Name: ";
    $Body .= $Name;
    $Body .= "\n";
    $Body .= "Email: ";
    $Body .= $Email;
    $Body .= "\n";
    $Body .= "Message: ";
    $Body .= $Message;
    $Body .= "\n";

    // send email 
    $success mail($EmailTo$Subject$Body"From: <$EmailFrom>");

    // redirect to success page 
    if ($success){
      print 
    "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
    }
    else{
      print 
    "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    }
    ?>

    Thanks

  2. #2
    Join Date
    Jan 2010
    Location
    Sweden
    Posts
    130
    Where is $Email coming from in this line?
    Code:
    $EmailFrom = "".$Email."";
    You declare it four rows later.
    Please do the needful..

  3. #3
    Quote Originally Posted by dubdub View Post
    Where is $Email coming from in this line?
    Code:
    $EmailFrom = "".$Email."";
    You declare it four rows later.
    dubdub is right, this is the problem. All you have to do is move that line to below the line where $Email is declared.

    PHP Code:
    $EmailTo "email@email.com"
    $Subject "You have been contacted"
    $Name Trim(stripslashes($_POST['Name']));  
    $Email Trim(stripslashes($_POST['Email']));  
    $Message Trim(stripslashes($_POST['Message']));
    $EmailFrom "".$Email.""


    P.S.

    The quotes are kind of extraneous.
    Instead of:


    PHP Code:
    $EmailFrom "".$Email.""
    You could just as equally put:
    PHP Code:
    $EmailFrom $Email
    Last edited by HostForMe; 12-12-2010 at 12:09 PM.
    HostFor.Me — Experienced Customer Care & Support
    To us, hosting your website means more than simply providing web space on a server.
    Friendly services include: website design, development, marketing, troubleshooting, and advice.
    www.hostfor.me

  4. #4
    Join Date
    Jun 2006
    Location
    NY
    Posts
    485
    This is great!!!!

    Thank you so much

  5. #5
    Join Date
    Jun 2006
    Location
    NY
    Posts
    485
    Thanks, i like this one though its the most simple i could find lol and i dont need anything better.

Similar Threads

  1. PHP email script
    By jasonyyd in forum Programming Discussion
    Replies: 2
    Last Post: 08-15-2010, 08:27 PM
  2. php welcome email script
    By kipper01 in forum Reseller Hosting
    Replies: 5
    Last Post: 10-11-2009, 11:49 AM
  3. PHP Email Script
    By Adrnalnrsh in forum Programming Discussion
    Replies: 3
    Last Post: 02-18-2005, 03:14 PM
  4. free php eMail script
    By ws19 in forum Programming Discussion
    Replies: 2
    Last Post: 12-18-2004, 03:17 PM
  5. Email Forward To PHP Script...
    By Zoosushi in forum Programming Discussion
    Replies: 4
    Last Post: 01-08-2003, 09:16 AM

Posting Permissions

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