Jump to content

Submit button changes where the form submits to?


Allenph9

Recommended Posts

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 :P) 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>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.