Re: $_POST to function?

From: Date: Fri, 24 Feb 2006 16:18:08 +0000
Subject: Re: $_POST to function?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-231033@lists.php.net to get a copy of this message
Dan Parry wrote:
Why are you passing the POST array? As it's superglobal why not just work directly on it within the function? Dan ----------------------------------------------------- Dan Parry Senior Developer Virtua Webtech Ltd http://www.virtuawebtech.co.uk -----Original Message----- From: Jason Gerfen [mailto:jason.gerfen@scl.utah.edu] Sent: 24 February 2006 15:27 To: PHP General (E-mail) Subject: [PHP] $_POST to function? I am not sure why this is not working. Aren't $_POST vars superglobals? I am trying to pass the $_POST array as an argument to a function and nothing is being returned. Any help is appreciated. return global_template( 3, $_POST, count( $_POST ), $message ); function global_template( $cmd, $args, $num, $message ) { echo "<pre>"; print_r( $args ); echo "</pre>"; } Perhaps I should post some more of the code I am working. I am attempting to create a simple method of outputing data to a template function which only holds html data to be displayed on the browser. Here is a quick overview, perhaps I cannot do this.
index.php calls this: $data = chooser( $_SESSION['a'], $_GET['b'], $_SESSION['c'], $_SESSION['d'] ); Contents of chooser function: function chooser( $level, $page, $user, $pass ) { if( $page == "global" ) { require 'global.inc.php'; $data = global_dhcp( $_SESSION['lvl'], $_POST['dn'], $_POST['lt'], $_POST['mlt'], $_POST['msc01'], $_POST['msc02'], $_POST['msc03'], $_POST['msc04'], $_POST['msc05'], $_POST['pxe'], $_POST['pxe01'], $_POST['pxe02'], $_POST['pxe03'], $_POST['pxe04'], $_POST['pxe05'], $_POST['pxe05'] ); } contents of global_dhcp function: function global_dhcp( $level, $domain, $lease, $mxlease, $msc01, $msc02, $msc03, $msc04, $msc05, $pxe, $pxe01, $pxe02, $pxe03, $pxe04, $pxe05, $pxe06 ) { global $defined, $error_message; require 'template.php'; if( ( empty( $domain ) ) || ( empty( $lease ) ) || ( empty( $mxlease ) ) ) { $db = db( $defined['dbhost'], $defined['username'], $defined['password'], $defined['dbname'] ); $sql = @mysql_query( "SELECT * FROM global", $db ) $args = @mysql_fetch_array( $sql_global ); @mysql_close( $db );
    $message = "message";
    return global_template( 1, $args, count( $args ), $message );
    logs( $error_message['valid'] );
} else { return global_template( 4, NULL, NULL, NULL, NULL ); logs( $error_message['usr_chk'] ); } } and the contents of the global_template function: function global_template( $cmd, $args, $num, $message, $errors ) { if( $cmd == 4 ) { $data = "<img src=\"images/error.jpg\">&nbsp;&nbsp;<blink><b>Error: </b></blink>You do not have proper access to use this utility. Your computer information has been recorded and the Administrator has been notified."; } return $data; } So in essence: index.php->chooser->global_dhcp->global_template->output to browser I hope that clarifies my problem a bit. -- Jason Gerfen "When asked what love is: Love is the Jager talking." ~Craig Baldo

« previous php.general (#231033) next »