I've created a mod for processing information posted by a return function from an online payment site. After It processes the information It must post some variables to another mod. I'm just starting in PHP programming and cant find a way for doing that without creating a form and forcing the user to click on a button.
Let's say my mod is called return.php and receives a number of posted fields from the payment link return function. This mod processes that information and creates two variables called $_ord_id (string) and $_purchased (yes/no).
After processing that infromation it must automaticaly redirect to a URL like http://mysite.com/mod.php?mod=ord ers&mode=return posting those two variables to the URL.
Now the question: What would be the code to do that redirection and post those variables?
Thanks for the help.
Airton
7 1792
Welcome to The Scripts!
You show a lot of text, but where is your code? If you want us to help you, show the code you have developed so far and we will have a look and try to see what you need to achieve your goal.
Ronald :cool:
the solution can be simple if you use a session.
[PHP]
if(count($_POST ) > 0){
// process the form
// put variables in the session
$_SESSION['ord_id'] = $_ord_id;
$_SESSION['purchased'] = $_purchased;
// redirect to other page
header('http://mysite.com/mod.php?mod=ord ers&mode=return ');
}
[/PHP]
If you do this it's best you include these pages in a master page and you start the session there. For security reasons you can unset the session variables when you finished processing them on the redirected page.
Sorry guys for not having posted my code. But now, here it goes:
Whem my client finishes the payment process at the on-line payment site it will return automaticaly to this script by calling the URL http://mysite.com/return.php and posting a number of values to it.
[PHP]// RECEIVES THE POST SENT BY BRPAY AND VALIDATE THE DATA
$BRpay = 'Comando=valida r';
$BRpay .= '&Token=1234567 890';
$Cabecalho = "";
foreach ($_POST as $key => $value){
$value = urlencode(strip slashes($value) );
$BRpay .= "&$key=$val ue";
}
if (function_exist s('curl_exec')) {
$curl = true;
}
elseif ( (PHP_VERSION >= 4.3) && ($fp = @fsockopen('ssl ://www.brpay.com.b r', 443, $errno, $errstr, 30)) ){
$fsocket = true;
}
elseif ($fp = @fsockopen('www .brpay.com.br', 80, $errno, $errstr, 30)){
$fsocket = true;
}
// SEND DATA BACK TO BRPAY FOR VALIDATION
if ($curl == true){
$ch = curl_init();
curl_setopt($ch , CURLOPT_URL, 'https://www.brpay.com.b r/Security/NPI/Default.aspx/');
curl_setopt($ch , CURLOPT_POST, true);
curl_setopt($ch , CURLOPT_POSTFIE LDS, $BRpay);
curl_setopt($ch , CURLOPT_RETURNT RANSFER, true);
curl_setopt($ch , CURLOPT_HEADER, false);
curl_setopt($ch , CURLOPT_TIMEOUT , 30);
curl_setopt($ch , CURLOPT_SSL_VER IFYPEER, false);
$resp = curl_exec($ch);
if (!tep_not_null( $resp)){
curl_setopt($ch , CURLOPT_URL, 'http://www.brpay.com.b r/Security/NPI/Default.aspx/');
$resp = curl_exec($ch);
}
curl_close($ch) ;
$confirma = (strcmp ($resp, "VERIFICADO ") == 0);
}
elseif ($fsocket == true){
$Cabecalho = "POST /Security/NPI/Default.aspx HTTP/1.0\r\n";
$Cabecalho .= "Content-Type: application/x-www-form-urlencoded\r\n" ;
$Cabecalho .= "Content-Length: " . strlen($BRpay) . "\r\n\r\n";
if ($fp || $errno>0){
fputs ($fp, $Cabecalho . $BRpay);
$confirma = false;
$resp = '';
while (!feof($fp)){
$res = @fgets ($fp, 1024);
$resp .= $res;
// Verifies if the transaction status is VERIFICADO (VERIFIED)
if (strcmp ($res, "VERIFICADO ") == 0){
confirma=true;
break;
}
}
fclose ($fp);
}
}
if (confirma){
$_purchased = 'yes';
}
else{
$_purchased = 'no';
}[/PHP]
At this point the script will process the posted fields and may or may not change the $_purchased value depending on the results (under development). The value for $_ord_id is also posted to this script.
After the processing the script must redirect to http://mysite.com/mod.php?mod=ord ers&mode=return posting $_purchased and $_ord_id to that URL. This is the part of the code that I need.
All the user interaction is done by this last URL.
Thanks for the help so far.
Airton
I've made some changes to my script and it's not working. I tried to use xwero's sugestion bu all I get is a blank page when the pay-link returns to my mod and it doesn't redirects to the URL it should. What coud be wrong?
Thanks for the help.
Airton
Here is the modified code:
[PHP]<?php
// RECEBE O POST ENVIADO PELA BRPAY E ADICIONA OS VALORES PARA VALIDAÇÃO DOS DADOS
$BRpay = 'Comando=valida r';
$BRpay .= '&Token=1234567 89';
$Header = '';
$confirma = false;
foreach ($_POST as $key => $value){
$value = urlencode(strip slashes($value) );
$BRpay .= "&$key=$val ue";
}
if ( (PHP_VERSION >= 4.3) && ($fp = @fsockopen ('ssl://www.brpay.com.b r', 443, $errno, $errstr, 30)) ){
$fsocket = true;
}
elseif ($fp = @fsockopen('www .brpay.com.br', 80, $errno, $errstr, 30)){
$fsocket = true;
}
// ENVIA DE VOLTA PARA A BRPAY OS DADOS PARA VALIDAÇÃO
if ($fsocket == true){
$Header = "POST /Security/NPI/Default.aspx HTTP/1.0\r\n";
$Header .= "Content-Type: application/x-www-form-urlencoded\r\n" ;
$Header .= "Content-Length: " . strlen($BRpay) . "\r\n\r\n";
if ($fp || $errno>0){
fputs ($fp, $Header . $BRpay);
$resp = '';
while (!feof($fp)){
$res = @fgets ($fp, 1024);
$resp .= $res;
if (strcmp ($res, "VERIFICADO ") == 0){
$confirma=true;
break;
}
}
fclose ($fp);
}
}
$_ord_id= $_POST['Referencia'];
if ($Confirma){
$_Status = 'OK';
}
else{
$_Status = 'NOK';
}
// REDIRECIONA PARA A FUNCAO DE RETORNO
$_SESSION['ord_id'] = $_ord_id;
$_SESSION['Status'] = $_Status;
// redirect to other page
header('http://www.hotspothost ing.com.br/mod.php?mod=ord ers&mode=return ');
?>[/PHP]
Where did you start your session?
For the session option to work you need to embed the page you got in a master page which handles the redirections. And in that page you start your session so you can get and set session variables for all the pages that are embedded.
a quick an dirty redirection masterpage example
[PHP]
// cache get variables for checking
$getParameter1 = $_GET['parameter1'];
// checking code here
// page redirection based on first parameter
switch($getPara meter1){
case 'a':
// cache get variables after first parameter for checking
$getParameter1_ 1 = $_GET['parameter1_1'];
// checking code here
// page redirection
include('page1. php')
break;
}
[/PHP]
if that page is named index.php all the urls are index.php?... The url to get you to page1.php is index.php?param eter1=a¶met er1_1=b.
You can have as many levels as you want ofcourse.
[PHP]<?php
header('http://www.hotspothost ing.com.br/mod.php?mod=ord ers&mode=return ');
?>[/PHP]
should be
[PHP]<?php
header('Locatio n: http://www.hotspothost ing.com.br/mod.php?mod=ord ers&mode=return ');
?>[/PHP]
Thank you guys for your help.
Talking to the developer of my shoping cart I got to know that I could use GET to pass the values to the mod, so I changed the last part of my code (based on the tips from xwero) as follows:
[PHP]$_ord_id= $_POST['Referencia'];
if ($Confirma){
$_Status = 'OK';
}
else{
$_Status = 'NOK';
}
// REDIRECTS TO phpCoin RETURN FUNCTION
$Header = 'Location: http://www.hotspothost ing.com.br/mod.php?mod=ord ers&mode=return &ord_id=';
$Header .= $_ord_id;
$Header .= '&Status=';
$Header .= $_Status;
// redirect to other page
header($Header) ;
[/PHP]
Now it's working as expected.
Thanks again.
Cheers :)
Airton
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mike |
last post by:
I'm used to unix/cgi scripts so im slightly out of my depth here.
Ive got an asp script for a website form which works fine.
What i want to do is also get the form to include the ip address of the
perosn sending the form ie
<input type=hidden name=env_report value=REMOTE_ADDR>
Anyone know how to apply this to this asp script below?:
<%
|
by: Surendra |
last post by:
I have this query that I need to use in an Update statement to
populate a field in the table by the value of Sq
----------------------------------------------------------------------------
Inline View Query:
Select Sq
from
(
Select substr(to_date(End_Date,"DD-MON-YYYY"),4), End_Date,
Rank() Over (Partition by substr(to_date(End_Date,"DD-MON-YYYY"),4)
Order by End_Date) As Sq
|
by: vbmax |
last post by:
Hi to all!
I have to write the following program.
1.User inputs a number (example: 5)
2.Then (because he entered 5) he enters 5 times, each time different,
3-placed number (example: 134, 256, 425, 253, 275)
3.then I have to find the lowest of those he entered and print it out
I have no idea how do I do that, because If the user enters a mubers
|
by: worzel |
last post by:
Hi All,
I am looking for a reg ex that will match email addresses withing <a
href=mailto blah > links.
Actually, I already crafted my own, but with a slight problem:
<a href="mailto:fred@blah.com"> emal me</a> woud be matched as expected, but
so will:
|
by: Jeremy Weiss |
last post by:
I'm trying to build a database that will handle the monthly billing needs of
a small company. I'm charting everything out and here's what I see:
table for customers
sub table to track payments received.
No biggie, right? Well, here's my problem. I don't know how to tell access
to modify everyone's account balance each month. And I can't just always
assume that their monthly bill is $16 just because their balance is $16. If
I do that...
| |
by: Timothy Shih |
last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I
wrote a simple function which takes in 2 buffers (one a byte buffer, one a
char buffer) and copies the contents of the byte buffer into the character
pointer. The code looks like the following:
#include <stdio.h>
#include <stdlib.h>
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
|
by: Jason |
last post by:
Hi,
I was wondering if any could point me to an example or give me ideas on how
to dynamically create a form based on a database table? So, I would have a
table designed to tell my application to create certain textboxes, labels,
and combo boxes? Any ideas would be appreciated.
Thanks
|
by: gunimpi |
last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431
********************************************************
VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help
wanted
********************************************************
For this teeny job, please refer to:
http://feeds.reddit.com/feed/8fu/?o=25
|
by: Tom |
last post by:
First, I posted a similar request for help in another group and now
don't find the posting. Problem with my newsreader perhaps ... but
apologies if this appears as a cross posting.
My code is inconsistent in the detection of a vertical scrollbar. This
involves situations when less than the client area is needed to hold
the small amount of data. The inconsistency is when adjusting the
panel size within or just below the bottom row....
|
by: tracy |
last post by:
Hi, I really need help.
I run this script and error message appeal as below:
drop trigger log_errors_trig;
drop trigger log_errors_trig
ERROR at line 1:
ORA04080: trigger 'LOG_ERRORS-TRIG' does not exist
drop table log_errors_tab;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |