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

Archived

This topic is now archived and is closed to further replies.

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