Using PHP to find MySQL databases...?
-
I want "username" to be stored into a variable and then check if the MySQL database exists with that name..I am making a site and whenever someone registers, a new DATABASE, not Table, DATABASE is created. I DONT want them to press submit but I want to be able to check if a database with the same username exists AS SOON as they take their pointer off the text area. How do I do this? In HTML, you could do something like this. <input type="text" id="noname" onblur="thefunctionIwant()" /> I don't want them to Post anything. Only when they take their focus off of the textarea. It's possible to do that with JavaScript but I need to use PHP to be able to do what Im planning to do... And then in JavaScript.. var nonamevalue = document.getElementById("noname").value; Is there a way to do the same JavaScript code above but using PHP? Thank you!
-
Answer:
You'll probably have to use AJAX to do what you're describing. AJAX is a technique in which you use Javascript code to send HTTP requests to your server, which will then run some PHP code and send back data in XML format to your Javascript code. Unfortunately, this is kinda complicated, so you'll have to do quite a bit of reading. W3Schools has some good AJAX tutorials: http://www.w3schools.com/Ajax/default.asp
Ben at Yahoo! Answers Visit the source
Other answers
Yes you can do it with javascritp but you need to use ajax technology (well ajax is almost same as javascript). What you need to do is look like easy. I suggest to show the button depend at the respond of the verification. Example: 1.Create your text box in your html page, inside a form. 2. use the function unblur to check if the username exist. 3.Create you function in javascript using ajax. inside here you will call the php script 4.if the username is available show the button if not just send a message. 5.Remember to create the php script to verify if the database is already exist, also, here you will show the button or the msg. If you need help please contact me. I can do it for you. Hope it help.
ruizerwin
I personally use cookies on my sites for logins and then grab data from the database... I have used sessions before but they are some what hard for newbs to use, so I wouldn't recommend that route. On the issue of the username availability they are using AJAX which is javascript that is used to output data from the server/database to the page without refreshing or changing anything but the relevant data.
plabig
You can't in PHP - PHP requires a request before it can work, especially for things such as MySQL queries and such. There's probably a ahck, but a hack is a hack and I don't endorse them. Also, I'd like to point out that the only way this will work if you have a seperate databases with a table that contained all the databases, because for PHP to create a connection, it needs to have a database name.
L.S. Hill
Related Q & A:
- How To Build Business Directory Using Php Mysql?Best solution by Stack Overflow
- How to completely backup all mysql databases?Best solution by Server Fault
- how delete node in xml file using php?Best solution by Stack Overflow
- How to read csv file using php?Best solution by Stack Overflow
- Why Can't I find my databases from Mysql on linux?Best solution by Database Administrators
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.