Connecting Tech Pros Worldwide Forums | Help | Site Map

test button to validate mysql info

Jeff
Guest
 
Posts: n/a
#1: Sep 15 '08
I know how to use php/mysql, but the html aspect of
what Im trying to do (if its even possible this way) is what Im
unsure
of.

I want to have a button that a user can hit to valid mysql info
before
submitting the full page of info. I know this doesnt work, but
something like the following:


<form method=POST action="http://mysite.com/send.php">
<input type=text name=user>
<button>
<?php
.... do mysql lookup here and let user know 'user' is
valid....
?>
</button>
..... many more input types here ...
<input type=submit name="Submit">
</form>


Im unsure if A) it will work this way and B) how do even do this?


Will it work this way? If so what do I fill in in the button area?
Ive wondered if I need/should use javascript, but in looking around
the web it seemed that wouldnt work easily, or would it?
I know that the 'user' information is posted in the FORM, so Im
unsure
how to get it into the php section anyhow.


Thanks for any help



Harlan Messinger
Guest
 
Posts: n/a
#2: Sep 15 '08

re: test button to validate mysql info


Jeff wrote:
Quote:
I know how to use php/mysql, but the html aspect of
what Im trying to do (if its even possible this way) is what Im
unsure
of.
>
I want to have a button that a user can hit to valid mysql info
before
submitting the full page of info. I know this doesnt work, but
something like the following:
>
>
<form method=POST action="http://mysite.com/send.php">
<input type=text name=user>
<button>
<?php
.... do mysql lookup here and let user know 'user' is
valid....
?>
</button>
.... many more input types here ...
<input type=submit name="Submit">
</form>
>
>
Im unsure if A) it will work this way and B) how do even do this?
>
Your PHP is back at the server. It isn't going to do anything until
something has been submitted to it for processing.

If you want to validate something within the browser, you need to use
Javascript. You *can* use AJAX or some other means of communicating with
the server without submitting the form, using Javascript to send the
request and process the response. You'd need to have a separate PHP
resource on the server to handle that kind of request and return the
appropriate response, which might be plain text, might be encoded as
XML, or might take some other form.
Jeff
Guest
 
Posts: n/a
#3: Sep 16 '08

re: test button to validate mysql info


On Sep 15, 12:22*pm, Harlan Messinger
<hmessinger.removet...@comcast.netwrote:
Quote:
Jeff wrote:
Quote:
I know how to use php/mysql, but the html aspect of
what Im trying to do (if its even possible this way) is what Im
unsure
of.
>
Quote:
I want to have a button that a user can hit to valid mysql info
before
submitting the full page of info. *I know this doesnt work, but
something like the following:
>
Quote:
<form method=POST action="http://mysite.com/send.php">
<input type=text name=user>
<button>
* * <?php
* * * * * * *.... do mysql lookup here and let user know 'user' is
valid....
* * ?>
</button>
.... many more input types here ...
<input type=submit name="Submit">
</form>
>
Quote:
Im unsure if A) it will work this way and B) how do even do this?
>
Your PHP is back at the server. It isn't going to do anything until
something has been submitted to it for processing.
>
If you want to validate something within the browser, you need to use
Javascript. You *can* use AJAX or some other means of communicating with
the server without submitting the form, using Javascript to send the
request and process the response. You'd need to have a separate PHP
resource on the server to handle that kind of request and return the
appropriate response, which might be plain text, might be encoded as
XML, or might take some other form.
Ok so I figured that part out thank you. I have the following:

function chk_user(form)
{
url="http://mysite.com/val.php?email=" + form.email.value +
"&user=" + form.user.value;
window.open(url);
}

Is there any way to pass back what my php script returns via
window.open or is
there another javascript call I need to do so?

Is this even possible?

Based on the return value i want to display a different image or text
or
whatever I decide to do.

Thanks again
Harlan Messinger
Guest
 
Posts: n/a
#4: Sep 16 '08

re: test button to validate mysql info


Jeff wrote:
Quote:
On Sep 15, 12:22 pm, Harlan Messinger
<hmessinger.removet...@comcast.netwrote:
Quote:
>Jeff wrote:
Quote:
>>I know how to use php/mysql, but the html aspect of
>>what Im trying to do (if its even possible this way) is what Im
>>unsure
>>of.
>>I want to have a button that a user can hit to valid mysql info
>>before
>>submitting the full page of info. I know this doesnt work, but
>>something like the following:
>><form method=POST action="http://mysite.com/send.php">
>><input type=text name=user>
>><button>
>> <?php
>> .... do mysql lookup here and let user know 'user' is
>>valid....
>> ?>
>></button>
>>.... many more input types here ...
>><input type=submit name="Submit">
>></form>
>>Im unsure if A) it will work this way and B) how do even do this?
>Your PHP is back at the server. It isn't going to do anything until
>something has been submitted to it for processing.
>>
>If you want to validate something within the browser, you need to use
>Javascript. You *can* use AJAX or some other means of communicating with
>the server without submitting the form, using Javascript to send the
>request and process the response. You'd need to have a separate PHP
>resource on the server to handle that kind of request and return the
>appropriate response, which might be plain text, might be encoded as
>XML, or might take some other form.
>
Ok so I figured that part out thank you. I have the following:
>
function chk_user(form)
{
url="http://mysite.com/val.php?email=" + form.email.value +
"&user=" + form.user.value;
window.open(url);
}
>
Is there any way to pass back what my php script returns via
window.open or is
there another javascript call I need to do so?
I'm not sure that there aren't security restrictions that will prevent
this, depending on the browser, but

var win = window.open(url);
if (win.document....) ...

But doing this in another window is ugly. See information on
XMLHTTPRequest at http://en.wikipedia.org/wiki/XMLHttpRequest.
Closed Thread