Forum Moderators: open

Message Too Old, No Replies

Can not explode enter key

Ajax and PHP

         

liemonline

8:57 am on Jun 23, 2006 (gmt 0)



Hello,

I am trying to write a check multi domain script by Ajax & PHP. User will input multi domains in seperate line by enter after each domain.

However, my PHP script backend can not split domains user inputed. You can test my AJAX at: <snip>

My getdata.php code:

<?
print_r(explode("\r\n", $_GET['domain']));
?>

Hope someone can help me. Thank you.

Regards,

[edited by: trillianjedi at 9:04 am (utc) on June 23, 2006]
[edit reason] No specifics or URL's please... [/edit]

eelixduppy

3:36 pm on Jun 23, 2006 (gmt 0)



Welcome to WebmasterWorld liemonline!

Try POSTing the form instead of using GET. This would then change your code to this:
$domains = explode("\r\n", $_POST['domain']);

adni18

6:37 pm on Jun 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might also want to use (instead of explode), preg_split, because of the messed-up'ness of CRLF and LF on different OSes (sometimes it's \n and sometimes it's \r\n) so:

<?
print_r(preg_split("/\r{0,1}\n/", $_POST['domain']));
?>