Current location: Hot Scripts Forums » Programming Languages » PHP » ajax help


ajax help

Reply
  #1 (permalink)  
Old 11-10-10, 08:19 PM
phphelpme phphelpme is offline
Newbie Coder
 
Join Date: Jul 2010
Posts: 85
Thanks: 10
Thanked 0 Times in 0 Posts
ajax help

How would i add a new param and value? here is the code
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>
and here is the script , php
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>";
}
?>
Reply With Quote
  #2 (permalink)  
Old 11-11-10, 08:51 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
What param's do you want to add?
__________________
Jerry Broughton
Reply With Quote
The Following User Says Thank You to job0107 For This Useful Post:
phphelpme (11-12-10)
  #3 (permalink)  
Old 11-11-10, 03:58 PM
phphelpme phphelpme is offline
Newbie Coder
 
Join Date: Jul 2010
Posts: 85
Thanks: 10
Thanked 0 Times in 0 Posts
pass!

i want to add pass= so i can tell them on command that there passwords match
Reply With Quote
  #4 (permalink)  
Old 11-11-10, 04:35 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
Basically the POST param's are constructed just like GET param's.
Code:
paramName1=value1&paramName2=value2&paramName3=value3  etc...
Code:
params  = "passconfirm=" + passconfirm.value + "&pass=" + document.getElementById("input element id").value
where "input element id" would be the id of the input element you want to get the value from.

Also take a look at this tutorial: http://www.captain.at/howto-ajax-form-post-request.php
__________________
Jerry Broughton

Last edited by job0107; 11-11-10 at 09:52 PM.
Reply With Quote
  #5 (permalink)  
Old 11-12-10, 08:53 PM
phphelpme phphelpme is offline
Newbie Coder
 
Join Date: Jul 2010
Posts: 85
Thanks: 10
Thanked 0 Times in 0 Posts
Can you help me some more?

can you like edit my script for me? its not working!
Reply With Quote
Reply

Bookmarks

Tags
ajax, help me, javascrpt, php, php form


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
[SOLVED] AJAX Cache DAL JavaScript 7 06-17-08 09:15 AM
AJAX problem with php dynamic url scott2500uk PHP 3 10-28-06 10:33 AM
Want to bring your website up to date? Convert to AJAX! Anastas Job Offers & Assistance 7 08-22-06 04:13 AM
Need AJAX Engineer for Full time open source work in Seattle Ryan_Singer Job Offers & Assistance 0 02-15-06 04:57 PM


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