i successfully sign-up,but i like to check the null entry in the form before other check.please healp.

This Is My Sign-up From

<form action="signup.php" method="post">
       <label><b>User Name:</b></label><input type="text" name="login" /><br />
       <label><b>Password :</b></label><input type="text" name="password" /><br />
       <label><b>Confirm  :<br/></label><input type="text" name="confirm" /><br />
       <label><b>Email    :</b></label><input type="text" name="email" /><br />
       <label></label><b><input type="submit" value="Sign up" /></b>
</form>

And This Is My signup.php

<?php

$con=mysql_connect("host", "user", "pass") or die("cannot connect");

/* select the database */
mysql_select_db("db") or die("cannot select DB");

/* store the values submitted by form in variable */

$login = $_POST['login'];
$password = $_POST['password'];
$confirm  = $_POST['confirm';
$email    = $_POST['email'];

/* check if username is already in use or not */

$queryuser=mysql_query("SELECT * FROM tbl WHERE login='$login' ");
$checkuser=mysql_num_rows($queryuser);



if($checkuser != 0)
{ 
echo "<h1>Sorry,The Username *".$login."* Is Already Been Taken.</h1>";
echo "<h2>Please Try For A Different Username</h2>";}

else
 {

/* check if password and confirm password matched */
  if($password!= $confirm)
  { echo "<h1>Your Password and Confirm Password Were Not Matched</h1>"; }
  else
  {
/* write a query to insert user details into database */
$sql=mysql_query("INSERT INTO users (login, password,confirm,email)
VALUES
('$login', '$password','$confirm' , '$email')");
     if($sql)
        { echo "<h1>Wellcome To Signup Page</h1>";
         echo"<h2>Your Registration Succesfull</h2>"; }
     else
        { echo "<h1>Error In Registration</h1>".mysql_error(); }

/* closing the if else statements */
   }}
mysql_close($con)
?>

I am not confirm about that but may this solution can help you

if($login!='' && $password!='' && $confirm && $email){

//do some task here
}else{
//message here about form is empty
}

same thing can be done using java scripts.


If it helps you,please marks the thread as solved!!!

thanks
if i use your code before

if($checkuser != 0)

is it ok

if ($checkuser = "" || empty($checkuser) || $checkuser = null) {
\* do something  *\
}

Try this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.