473,397 Members | 1,960 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,397 software developers and data experts.

To create a checkavailabilty link in php for checking username on a hyperlink click

Here i created a javascript+php code by which u can create a check available link that u will usually see in many websites.Without submitting the whole form just u can check wther a username exist in the database or not
=================================================-=====
1:filenames: index.php

write a javascript fn like this in the head tag
<script language="javascript">
function x()
{
var y=document.form1.t.value;
open("newtest.php?value="+y,width='10', height='10');

}

</script>
<body>
<form id="form1" name="form1" method="get" action="newtext.php?value=y;">
<p>
<input name="t" type="text" id="t" />
<a href="#" onclick="javascript:x();">checkavailablity</a></p>
</form>
</body>
</html>

==================================================
In 2 nd Page(newtest.php) you can access this value like :

$get_value=$_REQUEST['value'];
//connect to the database
$query="select count(username) as us from <table> WHERE username='$get_value'";
$res=mysql_query($query);
while($row=mysql_fetch_array($res))
{
if($rows['us']>=1)
{
echo "<div align='center'><font color='red'><b>Sorry username exist</b></font></div>";
}
else
{
echo "<div align='center'><font color='blue'><b>You can use this username</b></font></div>";

}


}
Jun 28 '06 #1
1 4737
ronverdonk
4,258 Expert 4TB
I doesn't make a lot of difference. You still submit the variables. So, to pack it into one smaller routine and without messing without JavaScript, I give you the following code:
[PHP]<?php
if (isset($_POST['_submit'])) {
$get_value=$_POST['t'];
//connect to the database
$res=mysql_query("select * from <table> WHERE user='$get_value'");
if (mysql_num_rows($res)>0)
echo "<div align='center'><font color='red'><b>Sorry, username already exists, choose another one</b></font></div>";
else
echo "<div align='center'><font color='blue'><b>You can use this username</b></font></div>";
}
?>
<body>
<form method="POST" action="testit.php">
<p><center>
Type your text <input name="t" type="text" />
<input type="submit" value="search" />
<input type="hidden" name="_submit" value="1" />
</center>
</form>
</body>
</html>[/PHP]

Ronald :cool:
Jul 21 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: lkrubner | last post by:
I have a webserver through Rackspace. I create a domain. I create an FTP user. I upload some files. I create a database called testOfSetupScript and then I create a database user named setup. I...
3
by: VIJAY KUMAR | last post by:
Hi pals, I am using 2 web forms (pages). In first page, i have Datagrid control and on second page i have a hyper link control to the first page and Add value to the data grid/Database. ...
5
by: Janet | last post by:
The following html code appears in an ASP page. The hyperlink is set to white (see the page link color), but when the page renders in IE 6.0, it initially appears in maroon with a white border...
1
by: ksskumar | last post by:
Hi Friends, I am creating a application using C#. In that application I am using RichTextBox (System.Windows.Forms.RichTextBox). My query is how to create a file link in Rich text box. ...
5
by: Miguel Dias Moura | last post by:
Hello, i have an image with the following code: <img src="image/panel.gif" width="20" height="80" onClick="fnLoadNewWindow('http://www.google.com');"> When i click the image the Javascript...
2
by: Paolo | last post by:
While it is not a problem to create a mailto link in HTML, <a href= "mailto: <%# Databinder.Eval(Container.DataItem,"StoreEmail") %>" ><%#DataBinder.Eval(Container.DataItem,...
3
by: sloesch | last post by:
I am working with VS.net 2003, framework 1.1, developing with VB.net, and ASP.net, and I would like to know how you can create a dynamic hyperlink on the fly to a document stored in a SQL database?...
4
by: trichert | last post by:
Ok , developing a .aspx page with Visual Web Studio (the full page is at the bottom). Basically its a page that displays all my computers and the current logged on user pulling data from a live...
2
by: nja2222 | last post by:
I would like to create a page for my clients to login and check for updates on their accounts. Then I would like to create a page where my employees can login and make updates, specifically new file...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.