473,386 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

test button to validate mysql info

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
3 2274
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: I.P. | last post by:
Hi, it's my story. I have two 4.0.14 mysql server on one machine with win XP Professional polish version. First acts as master: on port 3300 Second acts as slave: on port 3301 below my...
0
by: I.P. | last post by:
No one has replied to my post. ----- Original Message ----- From: "I.P." <jancio_wodnik@wp.pl> To: <mysql@lists.mysql.com> Sent: Monday, August 18, 2003 1:01 PM Subject: mysql 4.0.14 +...
2
by: Matt | last post by:
In the following code, I have 2 questions regarding submit button with image. 1) Does this code <input type="image" name="populate" src="populate.gif"> behave the same as an HTML submit button...
15
by: lawrence | last post by:
Is this the correct way to test for a method before I use it? createRange() is, I believe, an IE only method. function wrapSelectionInTag(selection, tag) { if (document.selection.createRange)...
4
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I...
12
by: SJ | last post by:
Hope someone can help me out there I'm struggling with a particular problem... I have a form with many tab pages. On one tab page I've got a button which when clicked with a mouse adds items...
2
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
4
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
2
by: Bob | last post by:
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.