473,698 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

3 New Member
Here i created a javascript+php code by which u can create a check available link that u will usually see in many websites.Withou t 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="javas cript">
function x()
{
var y=document.form 1.t.value;
open("newtest.p hp?value="+y,wi dth='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="javasc ript:x();">chec kavailablity</a></p>
</form>
</body>
</html>

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

$get_value=$_RE QUEST['value'];
//connect to the database
$query="select count(username) as us from <table> WHERE username='$get_ value'";
$res=mysql_quer y($query);
while($row=mysq l_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 4751
ronverdonk
4,258 Recognized Expert Specialist
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=$_PO ST['t'];
//connect to the database
$res=mysql_quer y("select * from <table> WHERE user='$get_valu e'");
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
3052
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 write some PHP code which should, I think, be able to to auto create the tables. The SQL looks like this:
3
2246
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. Problem: when I click on the hyperlink on the second page, i am getting the first page with cahed data. But i didn't declare/Use code for cache data. when i
5
2696
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 around it. When the user clicks anywhere on the page, it turns white. Does anybody know how I can make it appear white when the page first renders? Response.Write("<html><body bgcolor=""#000000"" link=""#FFFFFF"" vlink=""#FFFFFF"">")
1
7429
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. Means, I want to embed file in Richtextbox. If the user click / doubleclick / Ctrl+click the link, that file should open. It is like hyperlink in HTML.
5
6036
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 Function fnLoadNewWindow opens a new window with google.com. The problem is that the mouse doesn't change when it's over the image to the
2
3924
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, "StoreEmail")%></a> I would like to do so using an ASP.Net 2. 0 hyperlink, or some other control (in Visual Web Developer 2005). What is the best way to do so?
3
12363
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? I would like to create a VB.net function that would do this, and I found this class *System.Web.UI.WebControls.HyperLink*, but I can not find any examples on generate a dynamic hyperlink. Basically, I want my function to generate an embedded...
4
3220
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 Altiris database. This works fine, i have added a feature with a link for me to click to run radmin against that computer so i can remote control it. The link shows properly when I hover over it "S:\apps\!drivers\WindowsETC\rview.bat PCNAME". ...
2
2778
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 uploads, to the clients accounts. I have seen similar sites everywhere, such as bank websites, USPS site, et cetera. What is required to accomplish this? I'm trying to do this with the PHP, MySQL and Adobe CS3 Master collection's 'Dreamweaver CS3' ...
0
8603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9026
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8861
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.