CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Simple Question: how to show a variable

Print topic Send  topic

Author Message
Lex84

Posts: 7
Posted: 03/28/2012, 12:49 AM

Hello, I am looking through the forum and documentation but I don't find what I am searching for.
It's a very simple thing:
Given a form, how can I retrieve and print on screen the data sent by the form using POST?

Assuming that I am into OnValidate event, how can I do a simple thing like this:
if(isset($_POST[submit]) {   
echo $_POST[color];   
}

This is just to give an idea, to explain my problem. Thanks in advance.
View profile  Send private message
Gena

Posts: 591
Posted: 03/28/2012, 1:07 AM

use CCGetFromPost(ParameterName, DefaultValue)

so

echo CCGetFromPost("color", "");

_________________
Gena
View profile  Send private message
Lex84

Posts: 7
Posted: 03/28/2012, 1:14 AM

Thanks for your kind reply Gena.
I have already tried that but I get the common error:
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\SP_Config\Index_events.php:26) in C:\AppServ\www\SP_Config\Index.php on line 322

even if before this error I get the ID of the object (database ID field) instead of the real value (database name field)

so I get
1  
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\SP_Config\Index_events.php:26) in C:\AppServ\www\SP_Config\Index.php on line 322

View profile  Send private message
Gena

Posts: 591
Posted: 03/28/2012, 1:27 AM

if you want echo - you got it. Sure you got also "Warning: Cannot modify header ...." because you use echo in inappropriate place of code..

and I am not sure about your second problem...
_________________
Gena
View profile  Send private message
Lex84

Posts: 7
Posted: 03/28/2012, 2:44 AM

So there is no way to take data (got from database) sent using a form and format them into a table? Everywhere I put an echo I get the header error
View profile  Send private message
Gena

Posts: 591
Posted: 03/28/2012, 2:48 AM

What are you going to do?????
_________________
Gena
View profile  Send private message
Lex84

Posts: 7
Posted: 03/28/2012, 2:58 AM

My intent is to create a datasheet selecting data from DB.
So I have a form with some select inputs where I'm gonna select product infos(got from DB), I would like to build this datasheet after sending the form and then choose if to print it and/or save the composed data into a DB table for example "datasheet_created"
View profile  Send private message
Lucius

Posts: 220
Posted: 03/28/2012, 4:31 AM

The most basic way to do it would be to:

- in a page add a single Label control (from forms) menu
- use beforeShow event on that label to SetValue() of the label - it will output your data.
- if you need HTML you can use the Label property to set it to output HTML
View profile  Send private message
Lex84

Posts: 7
Posted: 03/28/2012, 5:54 AM

Thx Lucius this is a good point where to start!

Well I have created the label control and I added this code into beforeShow event

$Label1->SetValue(CCGetFromPost("Apparecchio",""));

but nothing happens. :(

I think that the form is not sending data or is not working properly anyway. What can I check?

I ve placed this to see what happens, but I don't know if $_POST vars can be used this way inside CodeCharge:
if($_POST[submit]) {  
echo "yes";  
} else {  
echo "no";  
}

Obviously I am getting always "no"
View profile  Send private message
Lucius

Posts: 220
Posted: 03/28/2012, 6:40 AM

Hi,

Easiest way you can check very quickly your $_POST and $_GET and $_SESSION (or other) is to use:

  
print_r($_POST);  
print_r($_GET);  
...  

This code will print out your whole variable in form of an array, in a readable form (especially if you will check page source). Of course this will also generate the "header blabla" error, but for fast debugging and checking your variables it will do.

View profile  Send private message
Lex84

Posts: 7
Posted: 03/28/2012, 7:01 AM

ok just tried and I get absolutely nothing, an empty array. It seems that the problem is the form which doesn't send values, how is it possible?
View profile  Send private message
Lucius

Posts: 220
Posted: 03/28/2012, 12:58 PM

Depends on your form HTML, also if it was done by hand or you used CCS builders. But if those 2 arrays are empty after you submit the form then something is wrong with your form most likely.

Maybe try adding a very simple HTML form that will use GET method:

<form name="input" action="YOUR_RETURN_PAGE.PHP" method="get">  
Some input: <input type="text" name="input_value" />  
<input type="submit" value="Submit" />  
</form> 

See if this works on your page - you should see the result immediately as GET forms have the data passed in browser URL.

Try simple and experiment with more complex until you find the issue.

If you used CCS builder, then one things that might come to mind is lack of connection property in form properties (even if it does not use a DB directly it should have this property set to some DB), maybe some other property is also missing...
View profile  Send private message
Lex84

Posts: 7
Posted: 03/28/2012, 11:41 PM

Thx Lucius for your kindness!

I have tried what you wrote, it seems that values are correctly sent by the form. This is true also for my original form, I have changed the sent method to get and now values are appearing on the url. After this I did another test, I have tried print_r($_GET) but nothing happens even if the value is correctly sent through url. I have tried also
$Label1->SetValue(CCGetFromGet("Apparecchio",""));
but nothing happens :(
I'm going mad :-D
View profile  Send private message
clahti2

Posts: 107
Posted: 03/29/2012, 10:54 AM

Quote Lex84:
Thx Lucius for your kindness!

I have tried what you wrote, it seems that values are correctly sent by the form. This is true also for my original form, I have changed the sent method to get and now values are appearing on the url. After this I did another test, I have tried print_r($_GET) but nothing happens even if the value is correctly sent through url. I have tried also
$Label1->SetValue(CCGetFromGet("Apparecchio",""));
but nothing happens :(
I'm going mad :-D


You could also try echo CCGetQueryString("All",""); which gets all get and post vars at once
View profile  Send private message
Lucius

Posts: 220
Posted: 03/30/2012, 4:46 AM

It could be some server php.ini setting. Not really sure...

To be sure, create your own (not in CCS) php page that will display the above form, in a nutshell it should look like this:

test.php
  
<body>  
<form name="input" action="test.php" method="get">    
Some input: <input type="text" name="input_value" />    
<input type="submit" value="Submit" />  
<pre>  
<?php print_r($_GET); ?>   
</pre>   
</form>   
</body>  
 

This simply has to work, if you enter "sss" in the box and submit you should get:

  
Array  
(  
    [input_value] => sss  
)  
 
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.