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";

                  }

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);
      }
      
  ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.