Current location: Hot Scripts Forums » Programming Languages » PHP » Help with php and ajax!


Help with php and ajax!

Reply
  #1 (permalink)  
Old 11-18-10, 11:02 PM
phphelpme phphelpme is offline
Newbie Coder
 
Join Date: Jul 2010
Posts: 85
Thanks: 10
Thanked 0 Times in 0 Posts
Help with php and ajax!

Code:
<script>
function checkpasscon(passconfirm)
{
  if (passconfirm.value  == '')
  {
    document.getElementById('info4').innerHTML = ''
    return
  }

  params  = "passconfirm=" + passconfirm.value
  request = new ajaxRequest()
  request.open("POST", "checkconfirm.php", true)
  request.setRequestHeader("Content-type",
    "application/x-www-form-urlencoded")
  request.setRequestHeader("Content-length", params.length)
  request.setRequestHeader("Connection", "close")
  
  request.onreadystatechange = function()
  {
    if (this.readyState == 4)
    {
      if (this.status == 200)
      {
        if (this.responseText != null)
        {
          document.getElementById('info4').innerHTML =
            this.responseText
        }
        else alert("Ajax error: No data received")
      }
      else alert( "Ajax error: " + this.statusText)
    }
  }
  request.send(params)
}

function ajaxRequest()
{
  try
  {
    var request = new XMLHttpRequest()
  }
  catch(e1)
  {
    try
    {
      request = new ActiveXObject("Msxml2.XMLHTTP")
    }
    catch(e2)
    {
      try
      {
        request = new ActiveXObject("Microsoft.XMLHTTP")
      }
      catch(e3)
      {
        request = false
      }
    }
  }
  return request
}
</script>
PHP Code:

<?php // checkuser.php 
include_once 'functions.php'

if (isset(
$_POST['email'])) 

$pass sanitizeString($_POST['pass']); 
$passconfirm sanitizeString($_POST['passconfirm']); 

if (
$_POST['pass'] == $_POST['passconfirm']) 

echo 
"<img src='img/goodemail.jpg' Width='27' height='27'>"

else  

  echo 
"<font color='red'> <img src='img/erroremail.jpg' WIDTH='27' HEIGHT='27'>Passwords don't match!</font>"

?>
Can you add these params in the ajax , script? to where it can tell if they are matching.
Code:
params  = "passconfirm=" + passconfirm.value + "&pass=" + document.getElementById("input element id").value
THANKS
Reply With Quote
  #2 (permalink)  
Old 11-19-10, 05:38 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
There are 3 parts to this code.
You only have the AJAX part.
Where is the rest of the code?
__________________
Jerry Broughton
Reply With Quote
  #3 (permalink)  
Old 11-19-10, 05:29 PM
phphelpme phphelpme is offline
Newbie Coder
 
Join Date: Jul 2010
Posts: 85
Thanks: 10
Thanked 0 Times in 0 Posts
you mean like the MAIN page?
Reply With Quote
  #4 (permalink)  
Old 11-19-10, 06:42 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Well first, you have a form that calls the AJAX code.
And you have the AJAX code.
And then you have the PHP page that the AJAX code calls (checkconfirm.php).

These three parts make up the code.
Without all three parts, you can't make the code work.
And I wouldn't know how to help unless I know what's in all three parts.

You are showing two of the parts; The AJAX code and checkconfirm.php.
In order to finish the AJAX code, I would need to see the form.
__________________
Jerry Broughton
Reply With Quote
Reply

Bookmarks

Tags
ajax, javascript, php, php ajax, script


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ajax - getting variables from the php code. zippoxer JavaScript 6 03-24-09 01:12 AM
PHP and AJAX help please !!! Wanasa PHP 6 12-19-08 08:59 PM
[SOLVED] PHP AJAX and IE disabled option issue Dan Man PHP 1 08-26-08 02:34 PM
[For Hire] PHP, Mysql, ASP, AJAX programer t_narendra Job Offers & Assistance 2 05-21-07 09:35 AM
AJAX problem with php dynamic url scott2500uk PHP 3 10-28-06 10:33 AM


All times are GMT -5. The time now is 08:43 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.