Forum Moderators: coopster

Message Too Old, No Replies

how do i pass some variables back to the web page that called the PHP

         

fshaw

4:39 am on Jun 24, 2007 (gmt 0)

10+ Year Member



I have like three question all related in some way.

I need some help in paasing varables back to the actaul web page that called the server side php script in the first place?

Want i am trying to do is pass back to the web page that called my server sode script - i want to pass back values and these values need to set the propertys in the current web page that uses HTML and is a iframe construct?

<iframe id="ifrm" name="ifrm" src="$index" scrolling="no"
width="400" height="100" frameborder="0">
</iframe>

In the HTML construct above i want to set the src propery to a the value contained in the server side php script.

how can i do this and what is the best metord to do this type of thing.

note: I need to pass more then one proerty is there a esay way to do this?

The other property i want to set is either make a hidden DIv visable or a layer tag change it from hide to show example follows:

<layer name="foo" visability=hide>
<iframe id="ifrm" name="ifrm" src="$index" = scrolling="no"
width="400" height="100" frameborder="0">
</iframe>
</layer>

last but least should i use a hidden DIV or a layer what are the pros and cons and - I have heard it refered to as a hidden DIV but how is it done please give me a example.

THANKS

Frank H. Shaw

mattclayb

5:12 pm on Jun 24, 2007 (gmt 0)

10+ Year Member



you should look at W3Schools or Tizag at some introductory tutorials on passing variables in PHP and creating pages in CSS.

To return variables from a script you could simply url encode them in a 'header Location' string pointing at your original page. ie -

header("Location: youroriginalpage.php?Variable1=Value1&Variable2=Value2&Variable3=Value3");

this would send three variables via the $_GET method to 'youroriginalpage.php1 the variables would be -

$Variable1 = Value1
$Variable2 = Value2
$Variable3 = Value3

and you would capture them in 'youroriginalpage.php' like this -

$Variable1 = $_GET['Variable1'];
$Variable2 = $_GET['Variable2'];
$Variable3 = $_GET['Variable3'];

Bear in mind you should only use the $_GET method for non sensitive info, as it is visible in the URL. If you would like to hide the variables, use $_POST method (this would require using a different method than shown above)

mattclayb

5:21 pm on Jun 24, 2007 (gmt 0)

10+ Year Member



for the 'visibility' issue somthing like this should work -

//Variable that controls which CSS rule to use
//Send either display=yes or display=no to this page
//If yes display, if no hide

$display = $_GET['display'];

if ($display == "no"){
$visibility = 'display:none;';
}

css -

<div style="<?PHP print $visibility;?>" />
</div>

fshaw

10:11 pm on Jun 24, 2007 (gmt 0)

10+ Year Member



how does one return the variable from a server side php script to the web page if we are deal with senstive data so that the information is not being passed back in a get but some other more secured way then a get in teh address bar. Please explian that to me?

Thanks

Frank H. Shaw

mattclayb

8:14 pm on Jun 25, 2007 (gmt 0)

10+ Year Member



You could have the form and php that handles the visibility variable and css all on the same page.

in your form where the user selects the option that controls visibility, you would set the action as $_SERVER['PHP_SELF']; and the form method as 'POST' this will send the value of the form to itself (and refresh the page) via the hidden 'POST' method.

If you just want to control the visibility of a div you could also do a similar thing with Javascript which would mean that the page would not need to be reloaded. - but you may require other variable handling / script that could rule this option out.

fshaw

1:39 am on Jun 26, 2007 (gmt 0)

10+ Year Member



I want to do the processing of the submit button on the form on my web page using a server sode script - I do have a lot of things planed other then just parseing what was passed and return to the web page - I have simplifed the example so as to deal with only the interface the passing to the server side script i clearly understand and know what to do there - it is the passing back to the web page that can get a little tricky as i have found out - I do not really like the use of the GET because it posses security risk and i feel that there is a better solution then the GET - to pass back the varables back to the web page in the browser - but is of this point i am still trying to understand what and how to handel that. That is why i posted this thread to get ideas of my options.

THANKS

Frank H. Shaw

fshaw

2:40 am on Jun 26, 2007 (gmt 0)

10+ Year Member



Ok lets look at the POST - can i use a POST to send data back to my current web page from a server side PHP script - then the next question is how do i send the POST back with out user intervation from the server side script this would decrease the security issues that I addressed with the GET in the last message above. Is the POST the only way i can Send Varables back to the Web Page that called the script in the being. Now if I do use a POST how do I get around the processing of the POST which is of course $_POST in the web page so that the first time the logic will skip the parseing because there is nothing to parse until the user has pressed the summit button on the form in the web page. Any ideas of how to get around that.

THANKS

Frank H. Shaw