Validation for the SAME VALUE?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yuukiizawa
    New Member
    • Sep 2012
    • 10

    Validation for the SAME VALUE?

    How can I make a validation when user is doing input, and get the value of name is already in database?

    example of the form:
    ID=
    Name=
    @mail=

    I did using PHP Script but it didn't work.. so I think JQUERY is the answer, but I don't know how to make it, becoz I don't understand about Jquery.
    Please help me. Thankyou
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You're going to want to use PHP because only a client side script will be able to read the database. You should instead post the PHP script you tried in the PHP forum.

    Comment

    • yuukiizawa
      New Member
      • Sep 2012
      • 10

      #3
      I'm so sorry for the mistake :)
      Here they are...

      Code:
      <?php
      session_start();
      if (empty($_SESSION[username]) AND empty($_SESSION[password])){
        echo "<center>Use your account to use our program<br>";
        echo "<a href=../index.php><b>LOGIN</b></a></center>";
      }
      else{
      	?>
      
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>Untitled Document</title>
      
      
      </head>
      
      
      <body OnLoad="document.plants.plantsname.focus();">
      <!-- menu -->	
      		<div  id="menu">
      		</div>					
      		<!-- content-wrap starts here -->
      		<div id="content-wrap">
      				
      <script language="javascript">
      function validasi(form){
        if (form.plantsname.value == ""){
          alert("Please enter the name first");
          form.plantsname.focus();
          return (false);
        }
        
        return (true);
      }
      </script><center>
      <body OnLoad="document.plants.plantsname.focus();">
      
      
      
      <?php
      	$namakoneksi = mysql_connect("localhost","root","") or die ("Failed to connect");
      	mysql_select_db("tanamobat",$namakoneksi);
      ?>
      
      <p align="center"><font color="#CC0000">
      <?	
      	if (isset($_GET['pesan']))
      {
      	echo $_GET['pesan'];
      }
      ?>
      </font></p>
      
      
      <center>
      <form action="tanaman_aksi.php?menu=tanaman&act=input" method="post" enctype="multipart/form-data" onSubmit="return validasi(this)">
      	<table>
          <tr><td colspan="5" bgcolor="#333333" align="center"><font color="#FFFFFF" face="Tahoma, Geneva, sans-serif" size="-1">Input New Plants</font></td></tr>
          
      	<tr>
              <td> Plants Name &nbsp;&nbsp;<td> &nbsp; : &nbsp;<input type="text" name="plantsname" size="30" /></td></td>
          </tr>
          <tr>
              <td> Explanation &nbsp;&nbsp;</td><td> &nbsp; : </td>
          </tr>
          <tr>
              <td></td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<textarea name='isi_profil' style='width: 550px; height: 200px;'></textarea></td>
          </tr>
          </table>
          
          <table>
          <tr>
          	<td><input type="submit" value="Save" /></td>
              <td><input type="reset" value="Refresh" /></td>
              <td><input type="button" value="&nbsp;&nbsp;Cancel&nbsp;&nbsp;" onclick=self.history.back() class='back_inline'></td>
          </tr>
          </table>
          </form>
      </center>
      </body>
      </html>
      <?php } ?>

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        You did no validation in your PHP code.

        Comment

        Working...