Allenph9 Posted March 10, 2012 Share Posted March 10, 2012 So I posted something like this a while ago but i didn't get any particularly good answers so I redid it. this is what I have now. It takes clicking the reply three times before it changes changes the form but then after that initial session of reply button clicks it only takes two which is what I want. This is the last thing on my forum (at least till I find some other bug ) and I need it fixed but I can't figure it out. IT\t wouldn't be a huge issue but the thing is that the first reply you make someone would fill it all in and then press reply then they would lose all their stuff and have to start over before it was submitted, Help please! thanks! <form action="<?php if ($_SESSION['logged_in'] == '1') { if ((isset($_POST['reply_to_thread'])) && ($_SESSION['reply_has_been_clicked'] != '1')) { echo $this_thread_path; } elseif ((isset($_POST['reply_to_thread'])) && ($_SESSION['reply_has_been_clicked'] == '1')) { $_SESSION['reply_has_been_clicked'] = '0'; $_SESSION['came_from_a_page'] = '1'; echo 'thread_redirect.php'; }}?>" method='post'> <?php if ($_SESSION['logged_in'] == '1') { if ((isset($_POST['reply_to_thread'])) && ($_SESSION['reply_has_been_clicked'] != '1')) { echo '<textarea name="reply_body" cols="75" rows="10" style="resize:none; onKeyUp="limitText(this.form.reply_body,this.form.countdown,5000); onKeyDown="limitText(this.form.reply_body,this.form.countdown,5000);">Enter your reply here...</textarea><br><br><font size="1">(Maximum characters: 5000)<br> You have <input readonly type="text" name="countdown" size="3" value="5000"> characters left.</font><br>'; $_SESSION['reply_has_been_clicked'] = '1'; } } ?> <input type='submit' name='reply_to_thread' value="Reply"> <?php if (isset($_POST['reply_to_thread'])) { if ($_SESSION['logged_in'] != '1') { echo 'You need to be logged in!'; } } ?> </form> Quote Link to comment https://forums.phpfreaks.com/topic/258631-submit-button-changes-where-the-form-submits-to/ Share on other sites More sharing options...
Drummin Posted March 10, 2012 Share Posted March 10, 2012 You're over complicating things. Just require login to post to topic. <form method="post" action=""> <?php if (isset($_SESSION['logged_in'])) { echo '<textarea name="reply_body" cols="75" rows="10" style="resize:none; onKeyUp="limitText(this.form.reply_body,this.form.countdown,5000); onKeyDown="limitText(this.form.reply_body,this.form.countdown,5000);">Enter your reply here...</textarea><br><br><font size="1">(Maximum characters: 5000)<br> You have <input readonly type="text" name="countdown" size="3" value="5000"> characters left.</font><br>'; } ?> <input type='submit' name='reply_to_thread' value="Reply"> <?php if (isset($_POST['reply_to_thread']) && !isset($_SESSION['logged_in'])) { echo 'You need to be logged in!'; } ?> </form> Quote Link to comment https://forums.phpfreaks.com/topic/258631-submit-button-changes-where-the-form-submits-to/#findComment-1325785 Share on other sites More sharing options...
Allenph9 Posted March 10, 2012 Author Share Posted March 10, 2012 Got it. What i did was <?php if ($_SESSION['logged_in'] == '1') { if ((isset($_POST['reply_to_thread'])) && ($_SESSION['reply_has_been_clicked'] != '1')) { echo '<textarea name="reply_body" cols="75" rows="10" style="resize:none; onKeyUp="limitText(this.form.reply_body,this.form.countdown,5000); onKeyDown="limitText(this.form.reply_body,this.form.countdown,5000);">Enter your reply here...</textarea><br><br><font size="1">(Maximum characters: 5000)<br> You have <input readonly type="text" name="countdown" size="3" value="5000"> characters left.</font><br>'; $_SESSION['reply_has_been_clicked'] = '1'; } } ?> <input type='submit' name='reply_to_thread' value="Reply"> <?php if (isset($_POST['reply_to_thread'])) { if ($_SESSION['logged_in'] != '1') { echo 'You need to be logged in!'; } } ?> <input type='hidden' name='how_many_posts' value="<?php echo $number_of_posts;?>"> <?php echo $reply_echo; ?> then at the top if (isset($_POST['reply_to_thread'])) { if (($_SESSION['logged_in'] == '1') && ($_SESSION['reply_has_been_clicked'] == '1')){ $_SESSION['came_from_a_page'] = '1'; echo '<meta http-equiv="REFRESH" content="0;url=thread_redirect.php">'; } } ?> works perfectly funny what comes to you at 4 am in the morning...site is done Quote Link to comment https://forums.phpfreaks.com/topic/258631-submit-button-changes-where-the-form-submits-to/#findComment-1325786 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.