www.webdeveloper.com
Results 1 to 4 of 4

Thread: send message and username

  1. #1
    Join Date
    Nov 2009
    Posts
    4

    send message and username

    hello. i need a solution for my web project. it seams simple but i can't get it working.
    this is the deal:

    user is register and loged in. he is viewing someones profile. so i have a php on witch i have a username (in form of php variable) of user browsing the site (user1) AND username of user who's profile is viewed (user2).
    i need to have an option so that user browsing the site(users 1) can send a message to user2 without refreshing or redirecting page.

    i can successfully send message text to php that will write it into database via js file, i also can send a user2 username to php that will write it into database via js file but only separately.
    i need to send bouth message text (form) AND user2 username to php file that will write this to database. All WITHOUT refreshing page or redirecting (ajax).

    Please help!

  2. #2
    Join Date
    Nov 2009
    Posts
    4
    ok here some javascript code. this code updates original php files with text filled in the text box (write message) and sends it to the destination php (sendit.php) that writes data into database.

    function doHttpRequest2() { // This function does the AJAX request
    http.open("GET", "sendit.php?txt1="+document.getElementById('txt1').value, true);
    http.onreadystatechange = getHttpRes;
    http.send(null);
    }



    is there a way to pass a php variable $username2 to destination file (sendit.php) thrue this function?

  3. #3
    Join Date
    Nov 2009
    Posts
    4
    Quote Originally Posted by nibuster View Post
    ok here some javascript code. this code updates original php files with text filled in the text box (write message) and sends it to the destination php (sendit.php) that writes data into database.

    function doHttpRequest2() { // This function does the AJAX request
    http.open("GET", "sendit.php?txt1="+document.getElementById('txt1').value, true);
    http.onreadystatechange = getHttpRes;
    http.send(null);
    }



    is there a way to pass a php variable $username2 to destination file (sendit.php) thrue this function?
    txt1 is id of text area that is in the html file (form file).

  4. #4
    Join Date
    Nov 2009
    Posts
    4
    resolved! i'm not familiar with javascript so that's the reall problem. answer is
    function doHttpRequest2() { // This function does the AJAX request
    http.open("GET", "sendit.php?txt1="+document.getElementById('txt1').value+"&username= <?php echo ($username); ?>", true);
    http.onreadystatechange = getHttpRes;
    http.send(null);
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles