Jump to content

Recommended Posts

<?php
require 'databaseconnect.php';
if(isset($_POST['username']))
{
$username=$_POST['username'];
$query="SELECT `username` FROM `user` WHERE `username`='$username'";
if($run=mysql_query($query))
{

if(mysql_num_rows($run)==1)
{
echo 'user already exist';
}
else
{
echo'its fine';
}
}
}
?>


<form method="post" action="11.php">
<input name="username" type="text"/><br>
<input name="submit" type="submit"/>
</form>

like i enter blacktiger this user already in my database but when i click on button its show

its fine echo run .. why is not run user already exist..

Link to comment
https://forums.phpfreaks.com/topic/283512-what-problem-in-this-code/
Share on other sites

I would check that there is none with that username, if you have 2 or more already stored while comparing with "1", it will always allow yet another one.

if(mysql_num_rows($run) === 0){
  echo 'nobody with that username was found in database';
}
else{
  echo 'You cannot use this username';
}
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.