Forum Moderators: coopster

Message Too Old, No Replies

How to Redirect with specific value ..?

Redirection with value

         

prabironnet

5:33 pm on Nov 2, 2004 (gmt 0)

10+ Year Member



I want that when i recieve different values from "form page" i will mail myself all the details and redirect the user to another site for CR Card payment. What i need is redirect the user to another site along with the value of total amount of package .How can I do that. I have done the first part of mailing but dont know how to do the redirection in PHP ..Plz help I m new to PHP script

jatar_k

5:47 pm on Nov 2, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld prabironnet,

you could use the header [ca.php.net] function to redirect, remember to output nothing, not even a blank line, to the browser before the function call or it will give you an error about 'output already started at line x'.

Build your query string
send your email
call header and send them off to pay

DaButcher

7:05 pm on Nov 2, 2004 (gmt 0)

10+ Year Member



you might also consider using session variables for storing the user submitted data, as then it will work even if the users presses the "go back" button in his/her internet browser.

If you use sessions for non-vital data, remember to include the SID (Session ID) in href's, form action, etc.

eg:

<form action="?<?=SID?>" method="post" name="foo">

<a href="page2.php?<?=SID?>" title="yoyo in the bar">bar</a>

Why do you need this?

Well, if the client does not support session cookies, it's needed to keep the session alive!

If needed, I can provide an example code for sessions for you!

prabironnet

7:21 pm on Nov 2, 2004 (gmt 0)

10+ Year Member



Thanks to both of you for your advice . I just tried Header function after my mailing code and got this error
"Warning: Cannot modify header information - headers already sent by (output started at /home/custom/public_html/php/order_mail.php:24) in /home/custom/public_html/php/order_mail.php on line 25 "
.. Plz provide me the correct header function code

DaButcher

9:26 pm on Nov 2, 2004 (gmt 0)

10+ Year Member



"headers already sent", means that something was parsed before the header().

nothing can be parsed before the header()!
As little as " " in front of <?php, can cause this error..

prabironnet

7:39 am on Nov 5, 2004 (gmt 0)

10+ Year Member



I have tried Header function many time but could not get thru . Where exactly the code of Header comes. I got this error "Parse error: parse error, unexpected $ in /nfs/cust/4/35/44/544534/web/mail.php on line 169
"

Is there any other methogs available in PHP for redirection which also full fill my other needs...plzzzzz help

DaButcher

7:53 am on Nov 5, 2004 (gmt 0)

10+ Year Member



You can use the meta refresh..
dont use it on pages that google can crawl though, or google will penalize you!

<META HTTP-EQUIV=Refresh CONTENT="10; URL=ht*p://www.domain.tld/">

jatar_k

8:38 am on Nov 5, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



whats on line line 169?

and the line before probably too

prabironnet

4:22 am on Nov 6, 2004 (gmt 0)

10+ Year Member



Here is the total code .This code retrive the values from "form page" and mailing to specified email .This code is working fine .I want thet after mailing the user redirected to cr card payement site along with some value which is filled by the user. I tried Header function but culd'n t get thru . Plz provide me the correct code to do this .....thanks

>..............................<
<?
$to = $to;
$from = $from;
$email = $email;
$subject = $subject;
$message = $message;
$eventname = $eventname;
$startdate = $startdate;
$starttime = $starttime;
$enddate = $enddate;
$description = $description;
$email = $email;

$msg = "Message\n";
$msg .= " $message\n";
if ($eventname!= "") {
$msg .= "Event Name: ".$eventname."\n";
}
if ($startdate!= "") {
$msg .= "Start date: ".$startdate."\n";
}
if ($starttime!= "") {
$msg .= "Start Time :".$starttime."\n";
}
if ($enddate!= "") {
$msg .= "End Date: ".$enddate."\n";
}
if ($description!= "") {
$msg .= "Description: ".$description."\n";
}
if ($email!= "") {
$msg .= "Email: ".$email."\n";
}

$mailheaders = "From: Web Design tools ( $from )<> \n";
$mailheaders .= "Reply-To: $email\n\n";

mail($to, $subject, $msg, $mailheaders);

>.............................................<

eggy ricardo

10:15 am on Nov 6, 2004 (gmt 0)

10+ Year Member



EDIT: Sorry just pointed out an error that isn't an error.

My apologies

kumarsena

4:13 pm on Nov 6, 2004 (gmt 0)

10+ Year Member



at the end of your script add this bit of code..

header("Location: [example.com...]

somepage.php is the page you want to redirect to (where u may have ur CR processing or whatever)

now to allow for the total of all the packages or whatever to be carried forward you could use do the following

header("Location: [example.com...]

you can then get total=12345 in the somepage.php by using
$total = $_GET['total'];

and there u have a value to play with. just remember that using this method the toatl value passed to the new page is visible to the 'public', not very secure, but it depends on what data you wanna send, so...

go to [no.php.net...]
and look for HTTP GET variables: $_GET

hope it helps