Jump to content

Passing Multiline Strings


CWeaver

Recommended Posts

I'm doing this, so far:

<button name=edit value='Edit' class='SubmitButton' type=button onclick="javascript:window.location='TestimonialInput.php?Patient=<?php echo $Patient; ?>&Testimonial=<?php echo(trim($Testimonial));?>'">Edit</button>

I'm having trouble with values for $Testimonial that include more than one line. Fact is, it doesn't work at all. Furthermore, when I do this:

<?phpecho $Testimonial;?>

all of $Testimonial is returned on one line, even though the user has input text through a <TEXTAREA> with multiple returns. I know I've seen this somewhere before, this business of passing a string with new line characters in it, but I can't remember where. Anyone have an answer or a link to the manual page that defines the issue? Or maybe I'm going about this in all the wrong way. Take a look at how this page works. The Post New Topic and the Preview Post buttons are both 'Submit' buttons within a <FORM>. The data is being passed through the post method but I can't figure out how the receiving php script knows whether it was preview or post that was clicked.I would like to know how to pass the parameters correctly, but I would also like to know if there's a better way to go about this.

Link to comment
Share on other sites

I strongly recommend NOT passing multiple lines via the url. Infact, it CANNOT at all. :)If you want various lines to be posted/sent to the action page of the form, you must use POST method instead :)So replace the javascript with a multiline value in the url by just the url of the next page, but only open it after the data has been submitted instead of added to the url.

<form name='' action='TestimonialInput.php' method="post"><input type='hidden' name='Patient' value='<?php echo $Patient ?>'><textarea name='Testimonial' style="display:none"><?php echo $Testimonial ?></textarea><input type='submit' class='SubmitButton' value='Edit'></form>
:( Edited by Dan The Prof
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...