Crlf in ajax call 403 (Forbidden)

I’ve just switched hosts to eliminate my issue with the code.js file caching on my previous provider. I don’t have caching problems anymore but I write text to a file on the server with a php file being called with Ajax. If the text to be written contains a crlf, vbcrlf, chr(13) or seemingly anything that writes a new line it brings up 403 (Forbidden). With no crlf it works perfectly. Is there something I need to do server side to get this going?

Use the encodeURIComponent function:

http://wiki.nsbasic.com/EncodeURIComponent/decodeURIComponent

I’m aware of that but I’m writing an email to send by php from server. Text needs to be human friendly.

If you are creating the the email on the server use \n for a carriage return. If the text string for the email has carriage return/linefeeds (13/10s) then replace these with \n within the text before writing to your server.

John

Awesome thanks. I’ll give that a go

I’m not doing something quite right. I get this…

Sports Committee\n\nRegistration details for as follows;\n\nParent: \nEmail:

by doing this…

r = "\n"
Txt = “Thank you for registering your child with the Gordonton School Sports Committee” & r & r
Txt = Txt & “Registration details for " & UCase(ChildNameTB.text) & " as follows;” & r & r
Txt = Txt & "Parent: " & ParentNameTB.text & r & "Email: "

Any help greatly appreciated

Can you using HTML here?

r = "<br>"
Txt = ...

That got the string with "<br>" in the string same as “\n”

How are you displaying the text?

<?php

// Get the data from the client.
$myText = file_get_contents(‘php://input’);
//$myText = str_replace(file_get_contents(‘php://input’),"","\r\n");
$to = $_GET[‘EmailTo’];
$headers = $_GET[‘Headers’];
$subject = $_GET[‘Subject’];
$body = $myText;
mail($to, $subject, $body, $headers);
?>

Ah - I thought you were displaying it in AppStudio.

This worked after 6 hours of research & trials. I send string to server with a “|” at the end of each line on the email.

<?php_

// Get the data from the client._
$myText = file_get_contents('php://input');
//$body = $myText;_
$lines = str_getcsv ($myText,"|");
foreach($lines as $str){
    $body .= $str . "\r\n";
 }

 $to = $_GET['EmailTo'];
 $headers = $_GET['Headers'];
 $subject = $_GET['Subject'];

mail($to, $subject, $body, $headers);_
?>