Grow your CSS skills. Land your dream job.

get the $EmailFrom from user in contactform.php

  • # September 15, 2009 at 5:22 am

    Hi there. I just arrived and I am absolutely new in PHP…
    I use your Contact Form free download which is by the way great and easy to use, (many many thanks for sharing ).
    I uploaded it to server and it works like a charm EXEPTED : I can not change the email from variable in order to get it right….
    I received a test email sent from me and the variable $EmailFrom is of course not customize :? . How can I get it correctly filled up ?
    Thank you for your help
    Pls find under php code sample :

    Code:
    < ?php

    // CHANGE THE VARIABLES BELOW

    [b]$EmailFrom = "junk@junk.com";[color=#FF0000]//HERE MY IGNORANCE COMES AT ITS BEST[/color]
    $EmailTo = "myemail@mydomain.com";
    $Subject = "A message for you";

    $Name = Trim(stripslashes($_POST['Name']));
    $Email = Trim(stripslashes($_POST['Email']));
    $Message = Trim(stripslashes($_POST['Message']));

    // 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
    // CHANGE THE URL BELOW TO YOUR “THANK YOU” PAGE
    if ($success){
    print ““;
    }
    else{
    print ““;
    }
    ?>

    # September 16, 2009 at 6:07 am

    To customise the $EmailFrom variable you simple change the line in the php file as follows:

    Code:
    $EmailFrom = “example@gmail.com”;

    Obviously you put your email address instead of example@gmail.com

    Hope this is what you were looking for.
    Dave

    # September 16, 2009 at 12:20 pm

    or if your form has a part for the email to be added, the get the variable that was entered….

    $EmailFrom = $_REQUEST; //where email was the form element name="email"

    # September 17, 2009 at 3:15 am

    Hi to you 2.
    Sorry for my late reply.
    First to davesgonebananas :
    so with

    Code:
    $EmailFrom = “myownemail@mydomain.com”;

    I will get the adress of the person who sent me a message ? I am sure I am missing something, considering that I input already my own email adress in the variable :

    Code:
    $EmailTo = “myemail@mydomain.com”;

    Am I right? Or totally wrong :?
    thank you,

    # September 17, 2009 at 3:18 am

    Hi to you 2.
    and then to ikthius :
    By just inputing :

    Code:
    $EmailFrom = $_REQUEST['email'];

    I am done, or I need more modif ?
    I am so beginner in this…
    Thank you for any further help,

    # September 17, 2009 at 12:16 pm

    if your form has a user input field and has the attribute of name="email"

    when you submit the form it should be sent to your php file handling the contact script………

    so when the script is running, it takes the value of the input feild called email and assigns it to a variable called
    $EmailFrom

    does this make more sense?

    # September 17, 2009 at 2:14 pm

    Well yes, I get it better. :D
    my user has actually an input field for his email, the contact form is taken from this CSSTRICKS http://css-tricks.com/examples/ContactForm/
    I am gonna give it a try …
    Thank you !

    # September 17, 2009 at 5:22 pm

    think about your form first, this is where you are going to gather the information.

    in the script you really want to get the users email & post the contents of the form to someone else…..

    e.g.

    $to = "abc@abc.com"; this is going to the preson who needs the info
    $from = $_REQUEST; //this is from the person filling in the form

    later on, in same script, you can email yourself with the contents, and also send an email back to the person who filled in the form with a thank you email.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".