Appending text when submitting?

Status
Not open for further replies.

cpd

New member
Nov 1, 2006
61
0
0
Hours of Googling have resulted in crap.

I need to append text to the end of what a user has entered in a text field when they click the submit button, preferably doing this via php. But at this point, I don't really care.

So, if a person entered "pink roses" into the text box and clicked submit, I need to add something like "delivered" onto the end of it, so it all shows up as one variable, such as "blah.com?flowers=pink+roses+delivered"

Any thoughts? It seems like there has to be a simple way to do this, but I am just not finding it.
 


How are they selecting pink roses, drop down list, check boxes, type text in text input box?

Is your form sending the data to another page on your site for processing or to another site all together?
 
There are two ways you can do it:

1.) Use Javascript to alter the form before submitting it. Try something like:

document.getElementById("field_name").value += " delivered";

2.) Submit the form to your own PHP page and update the parameter before forwarding it to the correct page. This is a simple example of what you might do:

header('http://www.example.com/?'.$_GET['flowers'].'+delivered');
 
Sorry, that PHP statement should read:


header('http://www.example.com/?flowers='.$_GET['flowers'].'+delivered');
 
Cool, thanks. I'll explore the Javascript route, it's much appreciated. I'm a total hack with Javascript (and for that matter, PHP)--but I'm sure I can investigate how to do this.

I'd rather not send it to a separate page first, so this should work fine.

Thank you!
 
Status
Not open for further replies.