Jump to content

Redirect after button is pushed twice?


Allenph9

Recommended Posts

this is my code so far...

 


<form action="<?php if ($_SESSION['reply_has_been_clicked'] != '1') { echo '';} elseif ($_SESSION['reply_has_been_clicked'] == '1') {echo 'thread_redirect.php';}?>" method='post'>
<?php
$_SESSION['current_thread'] = $the_thread_title . '.php';
if (($_SESSION['logged_in'] == '1') && (isset($_POST['reply_to_thread'])) && ($_SESSION['reply_has_been_clicked'] != '1')) {
echo "<textarea name='thread_reply' style='resize:none;' cols='75' rows='10'>Enter your reply here...</textarea>";
echo "<br>";
$_SESSION['reply_has_been_clicked'] = '1';
} elseif (($_SESSION['logged_in'] != '1') && (isset($_POST['reply_to_thread']))) {
$reply_echo = 'You need to be logged in!';
}
?>
<input type='submit' name='reply_to_thread' value="Reply">
<?php
echo $reply_echo;
?>

 

so this works but it takes three button pushes to do the job. I can't think of anyother way to do it. help please!

Link to comment
Share on other sites

So I have tried to do this with php and failed. someonbe recommended java on another thread but...I havnt used java in a year or more and I have NEVER used it with html or php. So I was wondering if ya'll could help me come up with a script that would redirect only adter the button has been pushed twice... my attempt in php was...

 

<form action="<?php if ($_SESSION['reply_has_been_clicked'] != '1') { echo '';} elseif ($_SESSION['reply_has_been_clicked'] == '1') {echo 'thread_redirect.php';}?>" method='post'>
<?php
$_SESSION['current_thread'] = $the_thread_title . '.php';
if (($_SESSION['logged_in'] == '1') && (isset($_POST['reply_to_thread'])) && ($_SESSION['reply_has_been_clicked'] != '1')) {
echo "<textarea name='thread_reply' style='resize:none;' cols='75' rows='10'>Enter your reply here...</textarea>";
echo "<br>";
$_SESSION['reply_has_been_clicked'] = '1';
} elseif (($_SESSION['logged_in'] != '1') && (isset($_POST['reply_to_thread']))) {
$reply_echo = 'You need to be logged in!';
}
?>

 

that did the job but only after three button pushed. any ideas?

Link to comment
Share on other sites

If I understand you correctly.

You need to create a counter that starts with a zero value,

then, on every click on the button, advance the counter by one...

When the counter get to your desired number(2 in your case), then redirect...

 

In javascript it's very easy, just catch the onclick event.

And use preventDefault to prevent the form from submit the first time.

 

Hope this helped you.

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.