Jump to content

[SOLVED] prevent from REPETITIVE ENTRANCEs in DB


msafvati

Recommended Posts

Hi my friends

I have a question!

How can I prevent from REPETITIVE ENTRANCEs such as username that we want to don’t repititive in my database

Please help me

 

 

$a=odbc_result($res,'username');

                  if ($a==$_POST['t9']){

                  echo "Repititve!!!! in DB";

                  }

Link to comment
Share on other sites

My problem is solved .

I write this script and test it and it answer  to me.

Thanks my friend

<?php
  $conn=odbc_connect("test","","");
      $name=$_GET['txt'];
      $username=$_GET['un'];
  if (isset($_GET['txt'])){
            $qu="select * from tblTest where username like '".$_GET['un']."'";
            $res=odbc_do($conn,$qu);
            $a=odbc_result($res,'username');
            if ($a == $_GET['un']){
            echo "Duplicate Data";
            }
            else
            {
      $query="insert into tblTest(name,username)"."values ('$name','$username')";
            $res=odbc_do($conn,$query);
            if (odbc_num_rows($res) >= 1){
            echo "user has benn registered";
            }
            }
      odbc_close($conn);
      }
      
  ?>

Link to comment
Share on other sites

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.