SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict einSTein's Avatar
    Join Date
    Aug 2006
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    it must give login name is already exist (was "php probelm")

    the problem here is zt we have an already registered user in database and we make register wz the same name so it must give login name is already exist, but here it dont take the if condition.
    Code PHP:
    include 'connect.php';
    $sql89 = mysql_query("SELECT * FROM login");
    if ($r['user'] == $_POST['user'])
    		{
    		echo "Login name is already exist";
     
    		}
    	else
    		{
    		//$nu=$_POST[user];
    		//$nu2=$nu . '_'. "mailbox";
    		echo $nu2;
    		include 'connect.php';
    		//entering the job seeker data in the employer table
    		$sql="INSERT INTO employer (name, addr, countr, ph1, ph2,
     fax, mail, URL, user, desc2)
    		VALUES
    			('$_POST[cname]','$_POST[add]','$_POST[cnt]','$_POST[ph]',
    '$_POST[ph2]','$_POST[fax]','$_POST[mail]','$_POST[url]',
    '$_POST[user]','$_POST[des]')";
    		$sql2="INSERT INTO login (user, pass, type)
    		VALUES
    		('$_POST[user]','$_POST[pass]','$_POST[type]')";
    		$sql3="INSERT INTO pc (user)      
    		VALUES
    		('$_POST[user]')";           //sql=2
    		if (!mysql_query($sql,$con))
    			{
    			die('Error: ' . mysql_error());
    			}
    			echo "<br>";
    		if (!mysql_query($sql2,$con))
    			{
    			die('Error: ' . mysql_error());
    			}
    			echo "<br>";
    		if (!mysql_query($sql3,$con))
    			{
    			die('Error: ' . mysql_error());
    			}
    			echo "<br>";
    		$nu=$_POST[user];
    		$nu2=$nu . '_'. "mailbox";
    		$sql4 = "CREATE TABLE `$nu2` (
    		`id` INT(3) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    		`mail` TEXT NOT NULL,
    		`title` VARCHAR(100) NOT NULL,
    		`type` VARCHAR(100) NOT NULL)";
    		if (!mysql_query($sql4,$con))
    			{
    			die('Error: ' . mysql_error());
    			}
    		$location = "index.php"; 
    		$seconds = "3"; 
    		$meta = "<META HTTP-EQUIV=Refresh CONTENT=\"$seconds; URL=$location\">"; 
    		mysql_query($sql4,$con);
    		echo"<center>";
    		echo "<br>Thanks for registration";
    		echo "<br>You can now LOGIN";
    		echo"</center>";
    		echo $meta;
    		exit();
     
    		}
    	}

  2. #2
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    i don't understand your question because of your bad english with no punctuation.

    however, i do see a serious problem with your code. you are inserting in to the employer table before inserting in to the user table. i assume you have a primary or unique index on user, and that you don't want duplicate users? with your code, a new user will be able to add entries for other users just be specifying that other user's username.

  3. #3
    SitePoint Member swatij's Avatar
    Join Date
    Jul 2007
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    If your code is intend to avoid duplicate user in login then, I think you should put your first 3 lines like I have given below and I hope your problem will be solved.

    #=============================
    include 'connect.php';
    $sql89 = mysql_query("SELECT * FROM login where user='".$_POST['user']."' ");
    $r=mysql_num_rows($sql89);
    if ($r >=1)
    echo "Login name is already exist";
    else
    {
    //your rest of the code...
    }


    Regards,
    Swati.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •