By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,156 Members | 1,009 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,156 IT Pros & Developers. It's quick & easy.

test button to validate mysql info

P: n/a
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
Sep 15 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Jeff wrote:
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.
Sep 15 '08 #2

P: n/a
On Sep 15, 12:22*pm, Harlan Messinger
<hmessinger.removet...@comcast.netwrote:
Jeff wrote:
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?

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
Sep 16 '08 #3

P: n/a
Jeff wrote:
On Sep 15, 12:22 pm, Harlan Messinger
<hmessinger.removet...@comcast.netwrote:
>Jeff wrote:
>>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.
Sep 16 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.