I am trying code a backend PHP script which uses the OS ticket API to submit a ticket.
I'm currently having an issue though, where in the message, at the top I want some other things displayed such as the users IP and some other information that they entered on the form.
At the moment this is sort of working. When a form is submitted, the data that it meant to appear in the message body appears but is not formatted. For example:
IP: [ip address]Phone Number: [phone number]Message: [message]
There is more data in the top of the message but I think you get the idea.
What I would like is for it to be displayed like this:
IP: [ip address]
Phone Number: [phone number]
Message:
[message]
My initial thought on this was to use "\n"
, but this just returned exactly what I wrote.
Next, after looking online, I tried "<br>"
but this also just returned exactly what I wrote.
I think my issue if that I am using ""
where I shouldn't be, but online they said to use them, and when I don't use them I get a PHP error when the script runs.
I should add that the data displayed in the main message all needs to go into one variable, for example:
$message = "IP Address: ".$ip."Phone Number: ".$phoneNumber."Message: ".$userMessage
Then $message
would be submitted to the API and put in the message for the admin to see in the OS ticket dashboard. When I was trying to add the spaces, I tried:
$message = "IP Address: ".$ip."<br>"."Phone Number: ".$phoneNumber."<br>"."Message: "."<br>".$userMessage
I also tried:
$message = "IP Address: ".$ip.<br>."Phone Number: ".$phoneNumber.<br>."Message: ".<br>.$userMessage
In place of <br>
and "<br>"
I also tried \n
and "\n"
, both returning the same results, either an error or returning exactly what is in-between the speak marks.
I'm sure it isn't that difficult to do this, but I'm out of ideas. Anyone know how to do this?
use PHP_EOL
- it is universal cross-platform way, php will know which end of line to apply according to the system.
$message = "IP Address: ".$ip.PHP_EOL."Phone Number: ".$phoneNumber.PHP_EOL."Message: ".PHP_EOL.$userMessage;