Advertisement
gitlez

Untitled

Jun 27th, 2011
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.41 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['create_accnt'])){
  3.     // Verify Information first.
  4.     if(strlen($_POST['fname']) === 0 || strlen($_POST['lname']) === 0 || strlen($_POST['mail']) === 0){
  5.         die('Not all Fields were entered properly. Go <a href="Javascript: history.go(-1)">Back</a> and correct missing fields.');
  6.     }
  7.     // POST Variables are stored in the array $_POST, not _$POST
  8.     // You will also want to look into 'SQL Injection protection' for the future.
  9.     $lname = $_POST['lname'];
  10.     $fname = $_POST['fname'];
  11.     $mail = $_POST['mail'];
  12.     mysql_connect("localhost", "root", "") or die("Unable to connect to MySQL");
  13.  
  14.     //echo "Connected!!<br>";// You have an error message that tells you if you are not connected, so no need for the connection varification. A lack of error message is confirmation enough.
  15.  
  16.     mysql_select_db("logindb") or die ("No such Database Found");
  17.  
  18.     //checking if data is already available or not
  19.     $query = mysql_query("SELECT fname,lname FROM login_details WHERE fname='{$fname}' AND lname='{$lname}' AND mail='{$mail}'"); // You had a typo lame -> lname
  20.  
  21.     //tells the no of rows for which the data matched
  22.     $rows = mysql_num_rows($query);
  23.  
  24.     //if data already present
  25.     if($rows > 0){
  26.         echo "data already present fill again";
  27.     }else{//if data is not in database
  28.         echo "value inserted";
  29.     }
  30. }else{
  31.     echo "not connected!!";
  32. }
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement