1

The following code is throwing a T-variable exception in line 10

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

//Set equal to email form textbox
$email_form = $_POST["email_text"];



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

//Create email headers
$headers = 'From: '.$email_form."\r\n".
@mail($email_to, $email_subject,$email_message,$headers);

When I change the = "Email: "$email_form""; to single quotes around the variables $email_form, it runs and throws no exception. However, it sends an email that says "Email: ''", as in, it reads the $email_form variable as blank, which it was not.

The HTML code for the form is below.

<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="email_text" 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>

Thanks for the help

4
  • $email_message = "Email: $email_form"; Commented Sep 5, 2012 at 21:55
  • 1
    Why would you ever suppress errors on mail()? I don't believe it can even throw an exception! Don't suppress problems, catch and handle appropriately, or fix them. Commented Sep 5, 2012 at 21:55
  • also: $headers = 'From: '.$email_form."\r\n"; overall, there are some formatting issues / bad practices Commented Sep 5, 2012 at 21:56
  • Thanks everyone for the comments. This is my first time really working with PHP so I am still learning. I am trying to get the web form to deliver the textbox input to an e-mail address. The form delivers an email, however, all it contains is "Email: ", even though input was inserted into the textbox. There seems to be a problem with the PHP script not picking up the input from the textbox. I am a bit stumped as to what is wrong. Commented Sep 5, 2012 at 23:51

2 Answers 2

4

Change:

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

to:

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

You forgot to concatenate.

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

3 Comments

I agree, but that does not seem to be the problem. It is still arriving in my e-mail as the following text: "Email: " (So does not display textbox input).
It sounds like $_POST["email_text"]; is empty. As @Brad said in the comments above, remove the @ from mail() and see what errors you get. Also, you have $email_form in your headers, why?
Deleted the entire header section, it really wasn't needed. Removed @ from mail(). Email sent, but textbox variable still empty. Still not showing input.
1

Change

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

to

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

Also it looks like you're missing a semicolon:

//Create email headers
$headers = 'From: '.$email_form."\r\n". <---

Comments

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.