This topic is locked
[SOLVED]

 BeforeAdd function uppercase

7/13/2006 4:56:14 PM
PHPRunner General questions
D
drh author

Hi forum,
I've been away for awhile now, and trying to get caught up. I have an app created using phprunner and I have had to modify it heavily in order to integrate it into a mambo website. i am using mysql as my db.
I need to change whatever text is entered into the form to uppercase prior to writing to the db. I read the howto article http://www.xlinesoft.com/articles/tabledata_uppercase.htm on this website.
Since I can't go back and recreate the app in phprunner (customization per above) I need to do this manually. In reviewing the howto, I am guessing that whatever custom code you add in the events tab gets written to the phprunner/include/_events.php file.
So I added a function to the _events.php file as such:
function BeforeAdd(&$values,$strWhere)

{

$values["Last_Name"]=strtoupper($values)["Last_Name"]);

return true;

}
Then I add a record with Last_Name in lowercase. I look at the record in the list, and it has not changed.
I have dinked with the code, but to no avail.
Anyone got any ideas?
Thanks in advance.
Dave

D
Dale 7/13/2006

Here is the snippet I use to uppercase the postal code field.

I think you just have a bracket missing. Have a compare.
function BeforeAdd(&$values)

{
// Parameters:

// $values - Array object.

// Each field on the Add form represented as 'Field name'-'Field value' pair
//** Custom code ****

// put your custom code here

$values["postal_zip_code"]=strtoupper($values["postal_zip_code"]);

return true;
// return true if you like to proceed with adding new record

// return false in other case
}
This worked fine, BUT the user can still type in lower or uppercase in the field.

So I added the text-transform: uppercase; to class in the style sheet.

Just a tip.

D
drh author 7/14/2006

Here is the snippet I use to uppercase the postal code field.

I think you just have a bracket missing. Have a compare.
function BeforeAdd(&$values)

{
// Parameters:

// $values - Array object.

// Each field on the Add form represented as 'Field name'-'Field value' pair
//** Custom code ****

// put your custom code here

$values["postal_zip_code"]=strtoupper($values["postal_zip_code"]);

return true;
// return true if you like to proceed with adding new record

// return false in other case
}
This worked fine, BUT the user can still type in lower or uppercase in the field.

So I added the text-transform: uppercase; to class in the style sheet.

Just a tip.


Hi Dale,

Thanks for the reply. Still striking out here. I actually had a paran in the wrong place when compared to your example. I changed the line, but it still does not change the field contents to uppercase.
I am not real familiar with the text-transform: uppercase and/or the style sheet. Will check it out soon. If I can get it so that when the user enters data into form it immediately changes the case to upper, then would the data get written to the db in uppercase, or whichever case the user originally used?
Here is my entire include/_events.php file. Very short. :-)
the BeforeEdit function works properly, but the BeforeAdd function does nothing.
Thanks for any help.
<?php^M
// Parameters:

// $values - Array object.

// Each field on the Add form represented as 'Field name'-'Field value' pair
//** Custom code ****^M
function BeforeEdit(&$values,$strWhere)

{

if ($values["Account_Status"] != "'N'") {

$values["Evaluation_Flag"] = "'E'";

}

return true;

}
function BeforeAdd(&$values)

{

$values["Last_Name"]=strtoupper($values["Last_Name"]);

return true;

}
?>
PS. Dale, hows that web app coming along? Sure looked nice the last time you let me check it out.

D
drh author 7/14/2006



Hi Dale,

Thanks for the reply. Still striking out here. I actually had a paran in the wrong place when compared to your example. I changed the line, but it still does not change the field contents to uppercase.
I am not real familiar with the text-transform: uppercase and/or the style sheet. Will check it out soon. If I can get it so that when the user enters data into form it immediately changes the case to upper, then would the data get written to the db in uppercase, or whichever case the user originally used?
Here is my entire include/_events.php file. Very short. :-)
the BeforeEdit function works properly, but the BeforeAdd function does nothing.
Thanks for any help.
<?php^M
// Parameters:

// $values - Array object.

// Each field on the Add form represented as 'Field name'-'Field value' pair
//** Custom code ****^M
function BeforeEdit(&$values,$strWhere)

{

if ($values["Account_Status"] != "'N'") {

$values["Evaluation_Flag"] = "'E'";

}

return true;

}
function BeforeAdd(&$values)

{

$values["Last_Name"]=strtoupper($values["Last_Name"]);

return true;

}
?>
PS. Dale, hows that web app coming along? Sure looked nice the last time you let me check it out.


Just thought I might add, I got my laptop back and opened up the project in phprunner. I followed the instructions per the above link and built my application. I then viewed the code in include/_events.php and copied the code php generated into my current include/_events.php file. Still doesn't work.
Now my application has been customized some, but the part that is customized deals with the login code. once a user gets logged into a webpage, they do not have to login again into the phprunner created app.
I think I probably have some syntax out of whack, but for the life of me, I cannot see it.
Thanks again.
Dave

D
drh author 7/14/2006



Just thought I might add, I got my laptop back and opened up the project in phprunner. I followed the instructions per the above link and built my application. I then viewed the code in include/_events.php and copied the code php generated into my current include/_events.php file. Still doesn't work.
Now my application has been customized some, but the part that is customized deals with the login code. once a user gets logged into a webpage, they do not have to login again into the phprunner created app.
I think I probably have some syntax out of whack, but for the life of me, I cannot see it.
Thanks again.
Dave


Okay. I win the dumbass award for this week. I was editting files for my http url, when I should have been editting files for my https url. DOH. So Dale was very much correct in the fact I had parans in the wrong place.
Thank you Thank you Thank you. Sorry to waste everyones time. But maybe, someone else can learn from my stupidity. ;-)
Dave