CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 need eqvuialent of "for each in request.form"

Print topic Send  topic

Author Message
CodeChargenewbie

Posts: 114
Posted: 10/11/2007, 2:33 PM

Is there an equivalent to "for each in request.form" in PHP? foreach() in php doesn't iterate in this manner. I know $_POST is essentially request.form, but how could one accomplish this same task in PHP?

Thank you in adavance.
View profile  Send private message
lvalverdeb

Posts: 299
Posted: 10/11/2007, 2:49 PM

try:
  
foreach($_POST as $fieldname=>$value) {  
     $settings = "\$" . $fieldname . "='" . $value . "';";  
   eval($settings);   
}  

_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4
View profile  Send private message
CodeChargenewbie

Posts: 114
Posted: 10/12/2007, 6:09 AM

Quote lvalverdeb:
try:
  
foreach($_POST as $fieldname=>$value) {  
     $settings = "\$" . $fieldname . "='" . $value . "';";  
   eval($settings);   
}  


Thanks! Most Excellent. I needed this to insert data into a log table and I think this may do the trick.

I do have a follow-up question, if you can be so kind to evaluate:

In the SQL statement for inserting data into the log table, do you have any idea why CCGetSession("UserID") produces no errors, yet $_SESSION["UserID"] gives me an "undefined index: UserID"?
View profile  Send private message
DonB
Posted: 10/12/2007, 5:25 PM

Because CCS is smart and checks whether the array element 'isset' before
attempting to reference it.

--
DonB

http://ccswiki.gotodon.net


"CodeChargenewbie" <CodeChargenewbie@forum.codecharge> wrote in message
news:5470f7215dd192@news.codecharge.com...
>
Quote lvalverdeb:
> try:
>
  
> foreach($_POST as $fieldname=>$value) {  
>      $settings = "\$" . $fieldname . "='" . $value . "';";  
>    eval($settings);  
> }  
> 
>
>
>
> Thanks! Most Excellent. I needed this to insert data into a log table
and I
> think this may do the trick.
>
> I do have a follow-up question, if you can be so kind to evaluate:
>
> In the SQL statement for inserting data into the log table, do you have
any
> idea why CCGetSession("UserID") produces no errors, yet
$_SESSION["UserID"]
> gives me an "undefined index: UserID"?
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

lvalverdeb

Posts: 299
Posted: 10/16/2007, 9:58 AM

I guess it is because CCGetSession is supposed to return a value (empty by default) if the session variable is not defined. The CCGetSession function looks like this(note the return statement):

  
function CCGetSession($parameter_name, $default_value = "")  
{  
    return isset($_SESSION[$parameter_name]) ? $_SESSION[$parameter_name] : $default_value;  
}  


_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.