Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem passing variables

Status
Not open for further replies.

deecee

Technical User
Aug 25, 2001
1,678
US
ok i have a form set up that inserts when a user hits submit, i then have the info from the form going to a thank you page where the user can see what info they entered as well as havin that info emaild to them as well to me. the info gets posted to the database fine but then on the thank youpage and email anything following a @ and a # sign get cut off. so if an email is entered as name@hotmail.com it will display as "name" or if someone enters their address with suite #2 then i will get "suite" and anything after and including the "#" sign will not show.

<signature>
sometime you just gotta say &quot;WHAT THE @#*% !!&quot;
</signature>
 
i am posting in the form

url.php?email=$email

then on the thank you page

<? echo &quot;$email&quot; ?>

<signature>
sometime you just gotta say &quot;WHAT THE @#*% !!&quot;
</signature>
 
i tried that

url.php?email=', urlencode($email), '&first=$first...

but it still cut it off

<signature>
sometime you just gotta say &quot;WHAT THE @#*% !!&quot;
</signature>
 
so can i display the email address from the url into the page without eveything after the @sign getting truncated

<signature>
sometime you just gotta say &quot;WHAT THE @#*% !!&quot;
</signature>
 
EEEK nevermind i was calling the wrong variable for the email...DOH! thanks for your help sleip. Im such a dolt

<signature>
sometime you just gotta say &quot;WHAT THE @#*% !!&quot;
</signature>
 
sleipnir214

I run this:
print '<pre>';
print_r ($_GET);
print_r($_POST) as you sugested and I got the follwoing

<pre>Array
(
)
1Array
(
)
1

why my redirect page does not see the form variables? the following is the code that sends the browser to the redirect page after inserting into mysql(inserting into mysql works perfectly) but the redirect page does not display the form variables. any idea?

AL Almeida
NT/DB Admin
&quot;May all those that come behind us, find us faithfull&quot;
 
Are you submitting values to the script to which you are directing the browser?

If you submit a form to foo.php, and foo.php uses an HTTP &quot;Location&quot; header to perform the redirect to bar.php, the data won't be there in bar.php. The browser will start a new connection to bar.php just as if you pointed the browser directly to it.

You can use URL-encoded values in your Location header to send GET-method form data into bar.php.

You can use session variables to make the values available to both scripts (foo.php will set the variables, bar.php will read them).

If bar.php resides on your server with foo.php, I recommend not performing a redirection if unavoidable. I'd just restructure my code and use include().

Want the best answers? Ask the best questions: TANSTAAFL!!
 
both foo.php and bar.php reside in the same folder

foo.php is a form that inserts data into a mysql db after that it goes and does this:
Code:
<?PHP
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? &quot;&&quot; : &quot;?&quot;;
    $insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
  }
  //echo $insertGoTo;
  header(sprintf(&quot;Location: %s&quot;, $insertGoTo));
  
}
?>

bar.php is thank you confirmation page that has to send the information to pay pal so it does have to have all the variables. Just because timing issue on my part, how would the line look like with the url_encode?

AL Almeida
NT/DB Admin
&quot;May all those that come behind us, find us faithfull&quot;
 
Just use include():

include ('bar.php');

When invoked using include(), the code in bar.php will behave as though it were typographically edited into the script that included it. All the variables are available and you don't have to worry about passing data around.

Assuming that &quot;success.php&quot; outputs a success message, &quot;failure.php&quot; outputs a failure message, and &quot;process.php&quot; contains user-defined functions to process the input, my code structure would be something like:

<?php
include ('process.php');

$result = process_input();

print '<html><body>.......&quot;;

switch ($result)
{
case 'GOOD':
include ('success.php');
break;
case 'BAD':
include ('failure.php');
}

print '</body></html>';

?>

There's no variable passing, the code can be reused through the use of include() in other scripts, and you aren't redirecting the browser anywhere.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top