close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

str_replace on data insert hidden field

Thread began 3/18/2010 6:13 am by henk303241 | Last modified 3/19/2010 3:01 pm by Eric Mittman | 1834 views | 5 replies |

henk303241

str_replace on data insert hidden field

Hi there,

I have 2 fieds in my database "page" and "url" (hidden field).
URL gets the data on insert from the PAGE form field:<?php echo((isset($_POST["page"]))?$_POST["page"]:"") ?>.
How can I accomplish a str_replace on this field.
I want to convert te page, for instance "is this a test?" to "this_is_a_test_".

I played around in the source with . "".((isset($_POST["page"]))?$_POST["page"]:"") ."" . but nothing I tried works :(.

Please help

Sign in to reply to this post

Eric Mittman

You will need to do this in the insert server behavior for the field values string.

php:
((isset($_POST["page"]))?str_replace(" ", "_", $_POST["page"]):"")



If you have any difficulty with this post back with the page in question.

Sign in to reply to this post

henk303241

Allright!
This did the trick.. but, if you want to replace more characters like &, ?, and -?

Sign in to reply to this post

Eric Mittman

You can compound the str_replace function calls to replace multiple characters like this:

php:
str_replace("&", "_", str_replace(" ", "_", $_POST["page"]))



This would replace any "&" characters with an underscore and replace any spaces with an underscore. There might be some better ways to do this in php but this should do the trick for you. Here is a link to the functions page on the php site for more info:

php.net/str_replace

Sign in to reply to this post

henk303241

Thanks for putting me on the right track. If you put it in an array it's shorter:

str_replace(( array(" ", "+", "&", "-", "'", "?")),'_',

Maybe this is helpful to somebody else.

Sign in to reply to this post

Eric Mittman

Nice work, that is much cleaner.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...