Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP button posts variables and redirects.

form button redirection without popup blocking

4:54 am on Sep 12, 2013 (gmt 0)

New User

joined:Sept 12, 2013
posts: 1
votes: 0

I was reading some old posts and was going to post my discoveries but the posts were too old. One was PHP Server Side Scripting Forum - Automatic posting varibles to another page while doing a redirect.

After working all day at it, I found a solution and I wanted to share it. It is a very simple concept.

Another thing I discovered while doing all this is that if you time the opening of the new page with a timer, Chrome will block the page.

However, If you open the new page with a button press, then Chrome will NOT block the page.

/** This is the script that will redraw current screen and submit to bank. */
echo '<script>'."\n" ;
echo 'function serverNotifySelected()'."\n" ;
echo '{'."\n" ;
echo ' window.open(\'\', \'BankPaymentScreen\');'."\n" ;
echo ' document.forms[\'bank_form\'].submit();'."\n" ;
echo ' document.forms[\'server_responder\'].submit();'."\n" ;
echo '}'."\n" ;
echo '</script>'."\n" ;

/** This form will be opened in a new window called BankPaymentScreen. */
echo '<form action="https://www.sandbox.bank.com/cgi-bin/webscr" name="bank_form" method="post" target="BankPaymentScreen">'."\n" ;
echo '<input type="hidden" name="cmd" value="_s-xclick">'."\n" ;
echo '<input type="hidden" name="custom" value="'.$transaction_start.'">'."\n" ;
echo '<input type="hidden" name="hosted_button_id" value="'.$single_product->hosted_button_id.'">'."\n" ;
echo '<table>'."\n" ;
echo ' <tr>'."\n";
echo ' <td><input type="hidden" name="'.$single_product->hide_name_a.'" value="'.$single_product->hide_value_a.'">Local</td>'."\n" ;
echo ' </tr>'."\n" ;
echo ' <tr>'."\n" ;
echo ' <td>'."\n" ;
echo ' <input type="hidden" name="'.$single_product->hide_name_b.'" value="'.$single_product->hide_value_b.'" />'.$single_product->short_desc.' $'.$adj_price.' USD'."\n" ;
echo ' </td>'."\n" ;
echo ' </tr>'."\n" ;
echo '</table>'."\n" ;
echo '<input type="hidden" name="currency_code" value="USD">'."\n" ;
echo '</form>'."\n" ;

/** This form will redraw the current page for approval. */
echo '<form action="ProductApprove.php" name="server_responder" method="post" target="_top">'."\n" ;
echo '<input type="hidden" name="trans" value="'.$transaction_start.'">'."\n" ;
echo '<input type="hidden" name="prod_id" value="'.$this->product_id.'">'."\n" ;
echo '</form>'."\n" ;

/** No form here just an input and a button. onClick will handle all the forms */
echo '<input type="image" src="https://www.sandbox.bank.com/en_US/i/btn/btn_purchaseimmediateCC_LG.gif" border="0" alt="This Bank - The safer, easier way to pay!" onclick="serverNotifySelected()">'."\n" ;
echo '<img alt="" border="0" src="https://www.sandbox.bank.com/en_US/i/scr/pixel.gif" width="1" height="1">'."\n" ;

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members