ohdang888 Posted December 24, 2007 Share Posted December 24, 2007 <form method="post"> E-Mail:<input type="text" name="Your E-mail" value="email"/> <br> <input type="submit" value="Submit"/> <form> <?php $email= $_POST["email"]; $emailfile = "../test.txt"; $FH = fopen($emailfile, 'a') or die("can't open file"); fwrite($FH,$email); fclose($FH);?> it was worknig earlier, then i was an idiot and fooled around with the code and can't remember how i had it. lol. the test.txt file is located 1 directory back.(thats why i have ../test.txt) Quote Link to comment https://forums.phpfreaks.com/topic/82997-solved-whats-wrong-with-form/ Share on other sites More sharing options...
ryanewing Posted December 24, 2007 Share Posted December 24, 2007 Shouldn't forms have actions? Quote Link to comment https://forums.phpfreaks.com/topic/82997-solved-whats-wrong-with-form/#findComment-422131 Share on other sites More sharing options...
trq Posted December 24, 2007 Share Posted December 24, 2007 This.... E-Mail:<input type="text" name="Your E-mail" value="email"/> should be.... E-Mail:<input type="text" name="email"/> Quote Link to comment https://forums.phpfreaks.com/topic/82997-solved-whats-wrong-with-form/#findComment-422132 Share on other sites More sharing options...
trq Posted December 24, 2007 Share Posted December 24, 2007 Your php should check the form was actually submitted also. Quote Link to comment https://forums.phpfreaks.com/topic/82997-solved-whats-wrong-with-form/#findComment-422133 Share on other sites More sharing options...
ohdang888 Posted December 24, 2007 Author Share Posted December 24, 2007 how do i do that???????? and the E-Mail:<input type="text" name="email"/> didn't work Quote Link to comment https://forums.phpfreaks.com/topic/82997-solved-whats-wrong-with-form/#findComment-422134 Share on other sites More sharing options...
trq Posted December 24, 2007 Share Posted December 24, 2007 <?php if (!isset($_POST['submit'])) {?> <form method="post"> E-Mail:<input type="text" name="email"/> <input type="submit" name="submit" value="Submit"/> <form> <?php } else { $email = $_POST["email"]; $emailfile = "../test.txt"; $FH = fopen($emailfile, 'a') or die("can't open file"); fwrite($FH,$email); fclose($FH); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/82997-solved-whats-wrong-with-form/#findComment-422136 Share on other sites More sharing options...
ohdang888 Posted December 24, 2007 Author Share Posted December 24, 2007 what does this mean???\ if (!isset($_POST['submit'])) {?> Quote Link to comment https://forums.phpfreaks.com/topic/82997-solved-whats-wrong-with-form/#findComment-422138 Share on other sites More sharing options...
dewey_witt Posted December 24, 2007 Share Posted December 24, 2007 if(!isset($_POST[''submit])) { <=== that means if there was no post made for the button submit. } else { <===this seys that if it has been posted do something else. } <====finaly this ends the whole if statment Quote Link to comment https://forums.phpfreaks.com/topic/82997-solved-whats-wrong-with-form/#findComment-422142 Share on other sites More sharing options...
ohdang888 Posted December 24, 2007 Author Share Posted December 24, 2007 thanks.. ONE MORE QUESTION i want to add a comma after each e-mail, so i wrote fwrite($FH,,) after the write e-mail code. its giving me a "parse error, unexpected ","" Quote Link to comment https://forums.phpfreaks.com/topic/82997-solved-whats-wrong-with-form/#findComment-422145 Share on other sites More sharing options...
trq Posted December 24, 2007 Share Posted December 24, 2007 fwrite($FH,$email . ','); Quote Link to comment https://forums.phpfreaks.com/topic/82997-solved-whats-wrong-with-form/#findComment-422148 Share on other sites More sharing options...
ohdang888 Posted December 24, 2007 Author Share Posted December 24, 2007 thanks thorpe! Quote Link to comment https://forums.phpfreaks.com/topic/82997-solved-whats-wrong-with-form/#findComment-422152 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.