maxtran2005 Posted November 22, 2006 Share Posted November 22, 2006 Hi, I have this script below. I can't make it work correctly, it kept going to the else statement. emaillist.txt contains email seperated by comma<?php if ($_SERVER['REQUEST_METHOD'] == "POST") { $email = strip_tags($email); $str = strtoupper(file_get_contents("emaillist.txt")); if (strpos($str, strtoupper($email))) { $feedback = "You already subscribed."; $subject = "Thank you"; $message = "$email and $feedback"; mail($email, $subject, $message); } else { $feedback = "You haven't subscribed yet. We will add you into our mailing list."; $subject = "Sorry"; $message = "$email and $feedback"; mail($email, $subject, $message); } } ?> <html> <head> <title></title> </head> <body> <?php if ($_SERVER['REQUEST_METHOD'] == "POST") { $email = $_POST['email']; echo("<p><b>The following message was sent to $email\n"); } else { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" METHOD="POST"> <p> Email: <input type="text" name="email" size="25"> </td> </tr> <input type="submit" value="Send Feedback"> </table> </p> </form> <?php } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/28107-check-user-input-script-is-provided-just-need-some-help/ Share on other sites More sharing options...
CheesierAngel Posted November 22, 2006 Share Posted November 22, 2006 Can you open the file and read the contents ?What happen if you echo the $str = strtoupper(file_get_contents("emaillist.txt")) ? Link to comment https://forums.phpfreaks.com/topic/28107-check-user-input-script-is-provided-just-need-some-help/#findComment-128570 Share on other sites More sharing options...
kenrbnsn Posted November 22, 2006 Share Posted November 22, 2006 Change this line (in two places)[code]<?phpif ($_SERVER['REQUEST_METHOD'] == "POST") { ?>[/code]to[code]<?phpif (isset($_POST['submit'])) { ?>[/code]and change this line[code]<input type="submit" value="Send Feedback">[/code]to[code]<input type="submit" value="Send Feedback" name="submit">[/code]These changes make it easier to check whether your form was submitted.Ken Link to comment https://forums.phpfreaks.com/topic/28107-check-user-input-script-is-provided-just-need-some-help/#findComment-128573 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.