SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Aug 2010
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help getting textarea to work with contact form

    I have a contact form that when hit submits it goes to my email. I've gotten every input to come across email except for the textarea box?

    Here is my PHP:
    Code:
    <?php 
    
    $errors = '';
    $myemail = 'baderup99@aol.com';//<-----Put Your email address here.
    
    
    if( empty($errors))
    {
    	$to = $myemail; 
    	$email_subject = "Registration submission from FacetoFaceTutoring: $name";
    	$email_body = "You have received a new registration. ".
    	" Here are the details:\n Name of Parent: $p_fname $p_lname \n Email of Parent: $p_email \n Name of Student: $s_fname  $s_lname \n Email of Student: $s_email \n Year: $year \n Subject: \n $subject"; 
    	
    	$headers = "From: $myemail"; 
    	$headers .= "Reply-To: $p_email";
    	
    	mail($to,$email_subject,$email_body,$headers);
    	//redirect to the 'thank you' page
    	header('Location: contact-form-thank-you.html');
    } 
    ?>
    Here is my HTML for the text area:

    Code:
    <label for="subject" class="fixed">Subject(s) student<br/> needs help in:<span class="red">*</span></label>
    		<textarea class="subject_text" cols="25" rows="5" id="subject" name="subject"></textarea>
    What am I doing wrong?

  2. #2
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you using anything like:

    $Subject = $_POST['subject'];

    Anywhere?
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  3. #3
    SitePoint Addict
    Join Date
    Aug 2010
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tangoforce View Post
    Are you using anything like:

    $Subject = $_POST['subject'];

    Anywhere?
    You know I don't know too much about PHP, Im more of a HTM/CSS guy.

    But I do have those $Subject = $_POST['subject']; in my form, but at the moment they are commented out because I wasn't exactly sure what they do.

    However, everything else is working, when I hit submit I have a bunch of inputs that translate into an email, yet textarea is the only one that doesn't come through.

    When looking at this: $Subject = $_POST['subject']; what part of the HTML is it relating to? the name attribute?

  4. #4
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Yes, the name attribute is added to the _POST array with the key of whatever the name attribute is. So $_POST['subject'] grabs your textarea contents.
    Ryan B | My Blog | Twitter

  5. #5
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Bades View Post
    But I do have those $Subject = $_POST['subject']; in my form, but at the moment they are commented out because I wasn't exactly sure what they do.
    If it was a script you've used from elsewhere (EG downloaded) and it was written to do what you're asking there is no need to start commenting out bits just because you don't understand them. Someone else did and thats why they are there

    Uncomment it and you should find it works.
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.


Bookmarks

Posting Permissions

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