Skip to main content
Participant
December 6, 2012
Question

Whats wrong with my php script?

  • December 6, 2012
  • 1 reply
  • 771 views

Hi, I'm (slowly) learning php and am having trouble getting this script to work. It is meant to redirect to paygol once the user clicks a button but for some reason it's not redirecting and just sits on a page telling the user they will be redirected soon....  Is there anything glaringly obvious that stands out to a more advanced php user than myself? There are no syntax errors in dreamweaver but i can't put my finger on what the problem is! Any tips/advice would be appreciated. Many thanks.

<?php

/**

* PaGol payment gateway script

*

* @package ClassiPress

* @author UTD

* @version 3.0

*

* @param int $post_id

* @param text $type

*

*/

// payment processing script that is used on the new ad confirmation page

// and also the ad dashboard so ad owners can pay for unpaid ads

function cp_dashboard_paygol_button($post_id, $type)

{

global $wpdb;

// figure out the number of days this ad was listed for

if (get_post_meta($post_id, 'cp_sys_ad_duration', true))

$prun_period = get_post_meta($post_id, 'cp_sys_ad_duration', true);

else

$prun_period = get_option('cp_prun_period');

$table_name_setting=get_option(table_name_setting);

$table_name_service=get_option(table_name_service);

$sql = "SELECT * FROM $table_name_setting";

$settings = $wpdb->get_results($sql);

foreach ($settings as $service)

{

// retrieve service information we need

$pg_serviceid = $service->pg_serviceid;

$pg_currency = $service->pg_currency;

$pg_price = $service->pg_price;

$pg_button = $service->pg_button;

}

// I used the same URL in all cases, just add different url parameter in the different cases.

$pg_cancel_url= home_url().’/’."payment/?cancel_post_id=$post_id";

$pg_notify_url =  home_url().’/’."payment/?success_post_id=$post_id";

$pg_return_url = home_url().’/’."payment/?success_post_id=$post_id";

?>

<script src="http://www.paygol.com/micropayment/js/pg.js" type="text/javascript"></script>

<link rel="stylesheet" href="http://www.paygol.com/micropayment/css/pg_pre.css" type="text/css" media="screen" />

<script type="text/javascript">

function pgredirect()

{

document.getElementById('pg_button').click();

}

</script>

<form name='pg_frm' method='post'>

<input type='hidden' name='pg_serviceid' value='<?=$pg_serviceid;?>'>

<input type='hidden' name='pg_currency' value='<?=$pg_currency;?>'>

<input type='hidden' name='pg_price' value='<?=$pg_price;?>'>

<input type='hidden' name='pg_name' value='<?=$pg_name;?>'>

<input type='hidden' name='pg_notify_url' value='<?=$pg_notify_url;?>'>

<input type='hidden' name='pg_return_url' value='<?=$pg_return_url;?>'>

<input type='hidden' name='pg_cancel_url' value='<?=$pg_cancel_url;?>'>

<center>

<input type='image' name='pg_button' id='pg_button' class='paygol' src='<?=$pg_button;?>' border='0' alt='PayGol' title='PayGol' onClick='pg_reDirect(this.form)'><br>

<input type='submit' onClick='pg_reDirect(this.form)' value="<?php _e('Continue','appthemes');?> &rsaquo;&rsaquo;" /></center>

<script type="text/javascript"> setTimeout("pgredirect()",500); </script>

</form>

<?php

}

?>

This topic has been closed for replies.

1 reply

Inspiring
December 12, 2012

Just a brief look and I see a couple of things.

  1. In function cp_dashboard_paygol_button($post_id, $type) {
    1. I don't see an ending  }
  2. I don't see anywhere in the script a redirect like a header command or opening a new window to a new URL.