0

I am trying to set up a basic textbox that when the submit button is pressed, it e-mails the contents of the box to me. The problem is that I keep getting blank emails. The PHP code for some reason is not accessing the textbox input.

//Two Email Lines
$email_to = "[email protected]";
$email_subject = "AUTO: REQUEST";

//Set equal to email form textbox
$email_form = $_POST['e3text'];


$email_message = "Email: " . $email_form . "";

//Create email headers
@mail($email_to, $email_subject,$email_message,$headers);

The HTML is below

    <div id="form">

    <form method="post" action="Email_Form_Script.php" 
      enctype="text/plain" 
      onsubmit="window.open('FormPopUp.html','popup','width=500,height=500,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');" >
  <div>
    <input type="text" class="text" name="e3text" id="emailForm" 
           value="Enter your e-mail address" 
           onfocus="if(this.value=='Enter your e-mail address') { this.value = '' }" 
           onblur="if(this.value=='') { this.value = 'Enter your e-mail address' }" />
    <input type="hidden" value="" name="email2"/>
    <input type="hidden" name="loc" value="en_US"/>
    <input type="submit" class="submit" value=""/>
  </div>
</form>
5
  • Let em clarify something. The e-mail is not completely empty. Its contents are "Email: ", as stated in the PHP code. It keeps reading the $email_form variable as blank. Commented Sep 8, 2012 at 17:50
  • 1
    html and php codes are in a same page ? Commented Sep 8, 2012 at 17:50
  • No, separate files. The php code is accessed through the action method of the form element. Commented Sep 8, 2012 at 17:52
  • You still don't actually have the textfield anywhere in your form. We got a good ways into this in your previous question stackoverflow.com/questions/12332623/…. If the e3text contains only email address, you need to get a body from somewhere. It's simply not in your form - where does it come from? Commented Sep 8, 2012 at 18:00
  • remove this from your code : enctype="text/plain" Commented Sep 8, 2012 at 18:00

1 Answer 1

0

remove enctype="text/plain" from the form tag. it works

Email_Form_Script.php

$email_to = "[email protected]";
$email_subject = "AUTO: REQUEST";
//Set equal to email form textbox
$email_form = $_POST['e3text'];
echo $email_form;
$email_message = "Email: " . $email_form . "";
//Create email headers
@mail($email_to, $email_subject,$email_message,$headers);

and x.html

<form method="post" action="Email_Form_Script.php"  onsubmit="window.open('FormPopUp.html','popup','width=500,height=500,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');" >
<div>
<input type="text" class="text" name="e3text" id="emailForm" value="Enter your e-mail address" onfocus="if(this.value=='Enter your e-mail address') { this.value = '' }" onblur="if(this.value=='') { this.value = 'Enter your e-mail address' }" />
<input type="hidden" value="" name="email2"/><input type="hidden" name="loc" value="en_US"/>
<input type="submit" class="submit" value=""/>
</div>

it's working for me.

Sign up to request clarification or add additional context in comments.

11 Comments

Removing it did not fix the problem for me. Is it possible that something else in my code is causing the variable to constantly be read as blank?
Still showing up as a blank variable input. Could it be a problem with the php settings on my server? Everything else in the php code is working, and I am getting an e-mail, but php is still reading the e3text as blank.
copy paste the edited answer. and echo $email_form before sending. that code is working for me. maybe you have a problem somewhere else
I copied code exactly and tried it. Same problem. I cannot figure out how an error elsewhere in the code (it all compiles fine) would cause the textbox to be read as blank. Any ideas?
You mean this (echo $email_form;) prints nothing? Weird problem
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.