OK. My 'logincontainer is hard coded HTML in the index.html page and is shown when a 'placeorder' button is clicked. The client enters their e-mail address in the only input visible and javascript addevent onchange checks to see if it is a valid e-mail or not. Above the input id 'login' is a span tag id 'loginrequest' which serves as server responceText. When the 'login.value' is a valid email address the second input is made visible id 'pass'. The 'pass' input addevent onchange query's the database with 'SELECT id FROM members WHERE login= '".($login)."' AND pass='".($pass)."'". The problem is

ResponceText span id 'loginrequest'

Parse error: syntax error, unexpected $end in D:\use_ide_1\UniServer\www\getmember.php on [B]line 26[/B]

MyDb Members Table Columns
id|status|started|name|login

Ajax call in index.js

var emailformat=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;
var lrq=document.getElementById('loginrequest');
var login=document.getElementById('login');
var passwordlist=document.getElementById('passwordlist');
var temail=document.getElementById('temail');//html table cell written to

function logincheck(){
var p=login.value;
if(p==' '){
lrq.innerHTML='Please Enter Your E-mail Address to login and register.';
return false;
}
if(emailformat.test(p)){
lrq.innerHTML='Please enter Your password.';
temail.innerHTML=p;
passwordlist.className='show'; 
return false; 
}
else{
lrq.innerHTML='Please Enter a Valid E-mail address.';
return true;//works
}} 

addEvent(login,'change',function(){logincheck();},false); 

var pass=document.getElementById('pass');

function getmember(p){
if(p==' '){//if 'pass.value' is empty?
lrq.innerHTML=' ';
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else{// code for IE6, IE5
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
lrq.innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open('GET','members.php?q='+p,true);//+p being 'pass.value'? no +e login.value?
xmlhttp.send();
}

addEvent(pass,'focus',function(){lrq.innerHTML='Minimum 8 characters, Maximum 12.';},false);

addEvent(pass,'change',function(){
var e=login.value;
var p=pass.value;
getmember(p);//Ajax call
},false);

getmember.php

1.	<?php

2.	$q=$_GET["q"];//p or 'pass.value' variable? no 'e' or 'login.value'

3.	$link=mysql_connect("localhost","root","root")or die(mysql_error( ));

4.	mysql_select_db("bwi",$link) or die(mysql_error( )); 

5.	$query=mysql_query("SELECT id FROM members WHERE login= '".($login)."' 
6.	AND pass='".($pass)."'")or die(mysql_error());      
7.	if($query_num_rows==0){       
8.	echo 'You must register';//responceText gets the echo?    
9.	}
10.	else if($query_num_rows ==1){

11.	while($row = mysql_fetch_array($query))

12.	{

13.	echo "Welcome back " . $row['name'] . ". You may change relevant items.";

14.	}

15.	mysql_close($link);
16.	?> 
//no line 26?

I've got quite an elegant get php that returns beautiful html to a main display div from MyDb but post is probably smarter and the 'SELECT id FROM members' syntax is the issue. Please help me if you can. I can't get the gist of the other posts as they involve starting sessions etc.:'(

I'm not that great at PHP so excuse me if this has no bearing what so ever. From red lines 7 to 14 starting with the if statement in your PHP file I see three opening brackets on line 7, 10 and 12 but only 2 closing brackets on lines 9 and 14. Is it possible you're missing one?

SethHall yes I believe you are right and the getmember.php has been amended by adding the second closing bracket at the end of the else statement though a third one maybe needed. The other problem was that 'get' only provides for a query of one variable. In this case the input value of input id/name 'pass'. I was trying to write an additional variable, the value of the input id 'login' to check that the mydb table members had both 'login' and 'pass' values that matched. I found out that that maybe the limitation of the 'get' method in that it provides a query with only one variable. If I'm wrong, please let me know. The following getmember.php produces this error because of the second variable added to a 'get' ajax call '$num=mysql_num_rows($query);' is not permited with the 'get' method and requiers a form post method when clicking a submit button. I want to validate the member before he sees the rest of the form so there is no submit button shown untill several inputs are validated on the server with the same 'get' method. With the post on several sites I still have some investigation to do as to 'get functions'

<?php
$q=$_GET["q"];
$link=mysql_connect("localhost","root","root")or die(mysql_error( ));
mysql_select_db("mydb",$link) or die(mysql_error( )); 
$query=mysql_query("SELECT * FROM members WHERE pass='".($q)."'")or die(mysql_error());
$num_rows=mysql_num_rows($query);//additional variable not allwed in 'get'?
if($num_row==0)
{
echo "You must register, no such email address was found";   
}	
else if(num_row==1)
{
while($row = mysql_fetch_array($query))
echo "Welcome back " . $row['name'] . ". You may change relevant items.";
}
}//added closing brace
mysql_close($link); 
?>

Error Reported with this getmember.php syntax

Notice: Undefined variable: num_row in D:\use_ide_1\UniServer\www\mexicali.php on line 7
You must register, no such email address was found

You're using $num_row but have it defined as $num_rows

SethHall
For your consideration, thanks.

007Julien @webdeveloper.com thanks for that, I posted on DaniWeb my thoughts that passing two variables with 'get' method was not possible. You are saying that it is? I guess I'll do some research on Mr. Peter Paul Koch to see if I can get a better understanding of using 'get' with multiple variables which might have been a better title for this post. I used the same post title on Daniweb, and Sitepoint so I'm going to copy and paste this reply to them.

Hey SethHall dito!
Gmanat SitePoint.com and webdev1958
at SitePoint.com As I posted at WebDeveloper.com, I'm really struggling here. Please help me if you can. I'm struggling to add multiple variables to a get Ajax call and adding a function that returns a different response if the database values don't match the input values.
I'm going to copy and paste to DaniWeb.com where I have posted under the same title. Thanks for any consideration in advance.
007Julienat WebDeveloper.com. well I'm realy strugling with this. I tried the article syntax to add multiple variables to the getmember.php but I get this error as responce text

Error!

Notice: Undefined variable: _Get in D:\use_ide_1\UniServer\www\mexicali.php on line 3

getmember.php

<?php
$login=$_GET['login'];
$pass=$_Get['pass'];//line 3 Error?
$link=mysql_connect("localhost","root","root")or die(mysql_error( ));
mysql_select_db("bwi",$link) or die(mysql_error( )); 
$query=mysql_query("SELECT * FROM members WHERE login='".($login)."' AND pass='".($pass)."'")or die(mysql_error());
while($row = mysql_fetch_array($query))
{
echo "Welcome back " . $row['name'] . ". You may change relevant items.";
}
mysql_close($link); 
?>

Ajax call

function getmember(){
var p=pass.value;
if(p==' '){
lrq.innerHTML=' ';
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else{// code for IE6, IE5
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
lrq.innerHTML=xmlhttp.responseText;
document.getElementById('pass2list').style.display='none';
document.getElementById('emailpasslist').style.display='none';
document.getElementById('loginrequest').style.display='block';
document.getElementById('changepasslist').className='show';
document.getElementById('continuelogin').style.visibility='visible';
document.getElementById('logincontainer').style.paddingBottom='12%';
//This works all the time even if the password and login don't match

//do I need an if (xmlhttp.readyState==4 && xmlhttp.status==404)

//i.e. when the values doen't match the database values?
}
}
var loginvalue=encodeURIComponent(document.getElementById('login').value)
var passvalue=encodeURIComponent(document.getElementById('pass').value)
xmlhttp.open('GET','mexicali.php?login='+loginvalue+'&pass='+passvalue,true);
xmlhttp.send(null);

//added as the article indicated but throws undefined variable error on 

// $pass=get['pass']; line 3?
}

I know I've simplified the variables and not stripped slashes or sanitized or MD5'd the password etc. but I'm just trying to understand what's going on. The dbase field 'login' is mysql phpadmin varchar(30) and the 'pass' field is varchar(12) but adding $login=(varchar)$_get; like the article showed for (int)$_get; produced an 'unexpected T error on line where I used (varchar)'? I still have to insert new members so I have to know what I'm doing before I proceed. For sure the insert members function will be a post onsubmit.
:'(

It tells you what the problem is undefined variable _Get. Now noticed you use a GET before line 3 on line 2 but what's the difference? It's CAPS, PHP is case sensitive so try

$pass=$_GET['pass'];

and see what happens. I dont see anything else with it.

SethHall your right, I aready changed it and got two variables into the getmembers.php like so.
getmembrs.php

<?php
$login=$_GET['login'];
$pass=$_GET['pass'];//line 3 Error?
$link=mysql_connect("localhost","root","root")or die(mysql_error( ));
mysql_select_db("mydb",$link) or die(mysql_error( )); 
$query=mysql_query("SELECT * FROM members WHERE login='".($login)."' AND pass='".($pass)."'")or die(mysql_error());
while($row = mysql_fetch_array($query))
{
echo "Welcome back " . $row['name'] . ". You may change relevant items.";
}
mysql_close($link); 
?>

Now I need to check for 'if (mysql_num_rows($result) == 0)' so I can return a different respnceText with echo.
Something Like This

<?php
$login=$_GET['login'];
$pass=$_GET['pass'];//line 3 Error?
$link=mysql_connect("localhost","root","root")or die(mysql_error( ));
mysql_select_db("bwi",$link) or die(mysql_error( )); 
$query=mysql_query("SELECT * FROM mexicalians WHERE login='".($login)."' AND pass='".($pass)."'")or die(mysql_error());
$num=mysql_num_rows($query);
if($num == 0)
{
echo "Sorry, No match found, please try again or register"//might be " " empty string?
}
elseif($num == 1)
{
echo "Welcome back " . $row['name'] . ". You may change relevant items.";
}
mysql_close($link); 
?>

Then of course I have to test the xhtml.responceText some how in the ajax call which I have no idea how to do, though I have a feeling it involves setting a var responce=xhtml.responceText. But how and where to place it in the Ajax call is hurting my head.
Ajax Call

function getmember(){
var responce=xhtml.responceText;
var p=pass.value;
if(p==' '){
lrq.innerHTML=' ';
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else{// code for IE6, IE5
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
lrq.innerHTML=xmlhttp.responseText;
if(responce=='something')//don't have a clue because the name returned by the php
//is the only thing I can think of checking for and there isn't any var for it
//so the responce==' ' if I echo " " where $num==0 in getmember.php?
{
document.getElementById('pass2list').style.display='none';
document.getElementById('emailpasslist').style.display='none';
document.getElementById('loginrequest').style.display='block';
document.getElementById('changepasslist').className='show';
document.getElementById('continuelogin').style.visibility='visible';
document.getElementById('logincontainer').style.paddingBottom='12%';
}
else if (responce!==' ')//don't have a clue
{
lrq.style.display='block';
lrq.innerTML='No password found, try again or Register.';
document.getElementById('pass2list').style.display='show';
document.getElementById('emailpasslist').style.display='show';
document.getElementById('loginrequest').style.display='block';
document.getElementById('changepasslist').className='show';
document.getElementById('continue').style.visibility='visible';
document.getElementById('logincontainer').style.paddingBottom='12%';
}
}
var loginvalue=document.getElementById('login').value;//thanks to 007julien at WebDeveloper.com
var passvalue=document.getElementById('pass').value;//added two variables to php
xmlhttp.open('GET','mexicali.php?login='+encodeURIComponent(loginvalue)+'&pass='+encodeURIComponent(passvalue),true);
xmlhttp.send();
}

I probably need Three options, another one for a member that forgot his password so I'll do a search on Ajax call login with forgoten password example?
Thanks for your consideration.:'(

OK. Thanks for the advice? 'Search: "Manipulating Form elements with xmlhttp.responseText" or "Handling xmlhttp.responseText" would have been good advice if the searches where not so convoluted with cryptic scenario solutions like this statement. At least it would have pointed me in the right direction! It makes me wonder whether the geniuses can actually speak English as their demonstration and communication skills appear to be left wanting'.
To others that suggested that posting to multiple forums "won't earn you friends or answers!" I will say that I have one too many friends already but I lack the education needed to enhance future prospects and that is why I spend my 'extra' time in multiple forums searching, not just for answers and certainly not for 'friends' but for 'direction' and 'education'!
Given that the current geniuses seem to lack the ability to grasp this simple concept, 'free education for all who are willing to put in the time to be educated', I've felt like it is some kind of secrete technology that others don't want to share and that I should throw in the towel.
Then I realize that that is the true power of the web, 'You can't hide a lit candle in a hay stack'.:(

THEFOOL a.k.a HEINZ PAUL STAPFF.

One more try? I've been trying to manipulate the login form with the xmlhttp.responseText written to a p tag id="loginrequest". I know the three responses I expect, that do work. I even wrote them to an array and called the last member of the array added with .push using .split(-1) but checklogin()/response handler will alert the innerHTML of 'loginrequest' or the .split(-1) of the array and still ignores 'if(loginrequest.innerHTML==' Something'){//do something}if(loginrequest.innerHTML=='Something Else'){//do something else}. The separate ifs are supposed to reveal extra form fields but don't.
1.)For a new member ie. not found on the db, 'loginrequest' reads, 'Not a member? Please register to submit your order.' A confirm password input should appear.
2.)For correct login and wrong password, ie. members login found but password is wrong, 'loginrequest' reads, 'Your password is wrong, you have 3 more attempts to get it right.' No other form fields appear until the input is entered correctly. If the third attempt fails a link should appear with id='emailpass'.
3.)For members found ie. when both login or password is found, 'loginrequest' reads, 'Welcome back " . $row[2] . ". You may change relevant items.' 3 links allowing them to change their password, billing and shipping info.

This appears to be standard site login, so the question is, "Can I use the responseText, either stored in an array or directly from the p tag to alter the form by checking against the innerHTML of the p tag or the value.slice(-1) of the array written to using a php get or does it have to be a post?"

I've tried three methods with getmember.php.
a.)if(xmlhttp.responseText=='Welcome back...
b.)if(loginrequest.innerHTML=='Welcome back...
C.)if(arrayvalue.slice(-1)=='Welcome back...

all three alert correctly but none affects the html output.:$

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.