0

I have a HTML form with the following:

<form method="POST" action="/subscribe/subscribe.php">
<p><input type="text" name "Email" value="[email protected]" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;"></p>
<p><input type="submit" value="Submit" name="Submit"></p>
</form>

I have the subscribe.php file with the following code:

# CONTENT
$email = $_POST['Email'];

# SAVE A COPY
$mailcopyfile = 'mailcopyfile.txt';
$fp = fopen($mailcopyfile, "a"); 
fputs($fp, $now . $email . ", ");
fclose($fp);

But in my mailcopyfile.txt all I get is commas for every new form submission like:

, , , , ,

What am I doing wrong? Why doesn't the emails show?

2
  • And why doesn't the time show in the text file with the $now command? Commented Dec 18, 2012 at 20:07
  • I thought I could just call it without defining it, first time writing php. But, it is not needed since this form should only hold emails. Commented Dec 18, 2012 at 20:24

1 Answer 1

2

There is an error in your form/input line:

<p><input type="text" name "Email" value="[email protected]" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;"></p>

after the name parameter is no equal sign. So i think this is the problem why there is no value in your text file.

<p><input type="text" name="Email" value="[email protected]" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;"></p>
Sign up to request clarification or add additional context in comments.

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.