slipstream180
-
Posts
4 -
Joined
-
Last visited
Never
Posts posted by slipstream180
-
-
OK. I think I understand that code snippet and that displaying a form and grabbing the resulting POSTs are two different things. However, does that mean there's really no way to return the POSTed values back to my calling function? (If I try something like your code snippet there, the function executes the code before the POSTed variable is captured and a NULL is returned to the calling function)
-
Here's all of prompt_user(), including HTML code:
function prompt_user($message) { if ($_POST['submit'] == null) { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Prompt User</title> </head> <body> <form id="message_form" action="path_to_G/G.php" method="post" name="msg_form" > <div> <table border="0"> <tr> <td align="right" valign="top"><b>Choose an option</b></td> <td valign="top" align="left"> <select name="election" id="user_select" > <?php if (isset($message['options'])) { foreach ($message['options'] as $option => $label) echo "<option value=\"$option\">$label</option>\n"; } // end if ?> </select></td> </tr> <tr> <td align="right" valign="top"><b></b></td> <td valign="top" align="left"> <input name="submit" value="Submit" type="submit" /></td> </tr> </table> </div> </form> </body> </html> <?php } else { echo "election: " . $_POST['election'] . "<br />"; return $_POST['election']; } } // end prompt_user
So, I am POSTing to G.php. However, if I POST to A.php, it calls a function a(), which does the same kind of thing prompt_user() does. (extract POSTed values and pass them on to another function). As a result, trying to return $_POST['election'] to A.php results in a functional error.
-
I’m having trouble displaying a form from within a nested function – maybe somebody’s faced this before.
Here’s the setup:
I have an initial starting page – let’s call it A.php.
Pathname for A.php: Localhost/A.php
A.php contains a form that extracts input from the client then processes it by calling a function – b(). b() kicks off some processing which nests down to a function f(). Once at f(), we then want to go back to the client and ask for some more input, before branching:
function f() { Require_once ‘path_to_G/G.php’; $result = prompt_user($options); If ($result == ‘a’) { // do A } else { // do B } } // end f()
prompt_user() is in G.php:
<?php function prompt_user($options) { ?> HTML form here <?php if (isset($_POST[‘submit’])) { // Capture users’ selection $response = $_POST[‘choice’]; return $response; } >?
If I try to execute this code, prompt_user() simply returns a null value without waiting for a response from the client. The form is displayed (the URI shows ‘localhost/A.php’) but when the “Submit” button is pushed, the client browser loads ‘path_to_G/G.php’ and quits.
How do I get my form displayed, and capture what’s POSTed without prompt_user() returning prematurely?
I’ve also tried first redirecting to G.php before trying to throw up the form, but then the program stack is lost and I can’t get the $response back to the calling function. (f()) Any ideas?
IPC functions running on Linux work, but fail on MacOS X
in PHP Coding Help
Posted
Hi All - I'm encountering a problem where I'm able to get the IPC message queue functions (msg_receive(), msg_send(), etc) working when running PHP on Ubuntu v9.04 Desktop, but on MacOS X v10.5.7 the msg_get_queue() function fails to retrieve the same message queue Resource across different PHP files.
Here is the test code I am using, which is taken from the "PHP Core Programming" book:
msg_server.php:
Then in a separate file, 'msg_client.php':
In this example, when running on Mac OS X, the server file never responds to the initial msg_send from msg_client.php. (Since the msg_get_queue() doesn't seem to access a common underlying queue for the "server". i.e. msg_get_queue(SERVER_QUEUE) returns a different resource in msg_client.php vs msg_server.php)
The MacOS X LAMP stack is configured with the following versions of software: Apache/2.0.59 (Unix) PHP/5.2.5 DAV/2 mod_ssl/2.0.59 OpenSSL/0.9.7l
The Ubuntu stack configuration:
Apache/2.2.11 (Ubuntu) PHP/5.2.6-Ubuntu4.1 with Suhosin-Patch mod_ssl/2.2.11 OpenSSL/0.9.8g
I don't know if this problem is a function of the underlying OS, or Apache, or something else...
We are using Ubuntu to serve our website, but we also use Mac OS X for development & prototyping, so we need identical functionality across platforms.
Thanks for any ideas in advance!