I've spent hours on a simple email form and finally figured out that for whatever reason, the php email code is simply not grabbing the data from the html form code. I have tried using both $_REQUEST and $_POST to grab the data, and it's just not doing it. Hoping I could get some help from someone regarding where the issue is. The html form code is as follows: <form method="post" action="submit.php" enctype="text/plain"> <font color="#000000" face="arial" size="2"><input name="name" size="17" type="text"> Your Name<br> <input name="url" size="17" value="" type="text"> Website URL<br> <input name="quicklink" size="17" type="text"> Quicklink to Article<br> <input name="email" size="17" type="text"> Your E-mail<br> </font> <select name="type" size="1"> <option selected="selected"> Select Article Type </option> <option> Strategy </option> <option> News </option> <option> History </option> <option> Other </option> </select> <br> <textarea cols="50" rows="10"></textarea><br> <input name="redirect" value="index.html" type="hidden"><input name="NEXT_URL" value="index.html" type="hidden"><input value="Send" type="submit"><input value="Clear" type="reset"></form> HTML: The code for submit.php is as follows: <?php $to="XXXXX; $email=$_POST['email']; $name=$_POST['name']; $type=$_POST['type']; $url=$_POST['url']; $quicklink=$_POST['quicklink']; $article=$_POST['article']; $headers="From:$from"; $subject="ArticleSubmission"; $fields=array(); $fields{"name"}="Name"; $fields{"email"}="Email"; $fields{"url"}="Website"; $fields{"quicklink"}="QuicklinktoArticle"; $fields{"type"}="ArticleType"; $fields{"article"}="Article"; $body="Wehavereceivedthefollowingarticle:\n\n"; foreach ($fieldsas$a=>$b {$body.=sprintf("%20s:%s\n", $b, $_REQUEST[$a]); } $headers2="From:XXXX"; $subject2="Thankyouforyoursubmission"; $autoreply="Thankyouforsubmittingyourarticle.Somebodywilllookitoverandwewillpostitonthewebsitewithbacklinksassoonaspossible."; if($email==''){ print"Youhavenotenteredanemail, pleasegobackandtryagain"; } else{ if($url==''){ print"YouhavenotenteredawebsiteURL, pleasegobackandtryagain"; } else{ $send=mail($to, $subject, $body, $headers); $send2=mail($from, $subject2, $autoreply, $headers2); if($send){ header("Location:http://www.XXXXX.com/submitted.html"); } else{ print"Weencounteredanerrorsendingyourmail, pleasenotifyXXXXX"; } } } ?> PHP: I always get the "You have not entered an email, please go back and try again" error, even though the box is filled when I submit it. Any ideas where I am going wrong? Thanks in advance.
The "enctype" attribute is the problem. enctype="text/plain" Code (markup): Try using: enctype="multipart/form-data" Code (markup):
Ok, nevermind. I'm an idiot, I was just loading a cached page. Cleared my cache and it works perfectly now Well, except the article variable is still empty, but that's because I never actually declared it in the initial html form Thanks a bunch flex!
Hmmm... try using enctype="multipart/form-data" instead of enctype="text/plain" If did not solved try Forcing your cache (Restart your Browser) since most guys will forgot that to erase and to try cache files!