Jump to content

Hi, how do i check if a textbox in a form is filled ?


jd2007

Recommended Posts

<?php
session_start();
header("Cache-control: private");
$theIP=$_SERVER['REMOTE_ADDR'];
if (!empty($_POST["email"])&&!empty($_POST["username"])&&!empty($_POST["password"])&&!empty($_POST["cpass"]))
{
similar_text($_POST["password"],$_POST["cpass"],$percent);
if ($percent!=100)
{
echo "Passwords don't match.";
}
else
{
  if (ereg("^[a-zA-Z0-9\_\-\.]+@[a-zA-Z]+\.[a-zA-Z\.\-]+$",$_POST["email"]))
  {
   include("connect.php");
   $query="SELECT username FROM users WHERE username='$_POST[username]'";
   $result=mysql_query($query) or die(mysql_error());
   if (mysql_num_rows($result)==0)
   {
    $query2="INSERT INTO users (username, password, email, confirm, credits, admin) VALUES ('$_POST[username]', '$_POST[password]', '$_POST[email]', '0', '5', '0')";
    $result2=mysql_query($query2) or die(mysql_error());
    if ($result2)
    {
     $x=rand(1, 10);
     $y=md5(rand(1, 10));
     $c=$x.$y;
     echo $c;
     
     $to=$_POST[email];
     $subject="Registration Confirmation Mail";
     $message="Type this code:$c into the text box on the confirmation page.";
     $headers = "From: NDS ROM\n";
     $mailed=mail($to, $subject, $message, $headers);
      if ($mailed)
      {
       echo "A confirmation mail was sent to your e-mail address. Please type the code provided in the mail into the confirmation box below.";
       echo "<form method='post' action='confirm.php?var2=$c&var3=$_POST[username]'>
             Confirmation Code: <input type='text' name='ccode'><br><br>
             <input type='submit' value='Confirm'>
             </form>";
       $queryx="DELETE FROM dip WHERE userip= '$theIP'";
       $resultx=mysql_query($queryx);      
      }
      else
      {
       $mailfail="Sending mail failed. Please try again later.";
       header("Location:register.php?mf=$mailfail");
      }
    }
    else
    {
     $userex="Username exists. Try another username";
     header("Location:register.php?ue=$userex");
    }
   }
   else
   {
    $notvalid="E-mail is not valid. Please enter a valid e-mail.";
    header("Location:register.php?nv=$notvalid");
   }
  }
  
}
}
else
{
$notfilled="Please make sure all fields are filled.";
header("Location:register.php?nf=$notfilled");
}



?>

 

not working... the code is above

Link to comment
Share on other sites

Guest Tim_Christopher

Try:

if (    empty($_POST["email"])
   || empty($_POST["username"])
   || empty($_POST["password"])
   || empty($_POST["cpass"]))
{
   echo 'One or more empty fields';
}
else
{
   echo 'All fields are not empty';
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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