registration form validation error..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
danielbala
Forum Newbie
Posts: 9
Joined: Tue Jan 24, 2012 4:27 pm

registration form validation error..

Post by danielbala »

include("config.php");
if(isset($_POST['submit'],$_POST['fullname'],$_POST['username'], $_POST['password'], $_POST['email'], $_POST['emp_role']))
{
$submit=$_POST['submit'];
$date=date("y-m-d");
$fullname = mysql_real_escape_string($_POST['fullname']);
$username = mysql_real_escape_string($_POST['username']);
$password = md5(mysql_real_escape_string($_POST['password']));
$email = mysql_real_escape_string($_POST['email']);
$emp_role = (int)$_POST['emp_role'];

if($submit)
{
if($fullname&&$username&&$password&&$email&&$emp_role)
{


$sql="INSERT INTO `logindetails` (fullname,username, password, email, emp_role,$date) VALUES ('$fullname',$username', '$password','$email','$emp_role','$date')";
$result=mysql_query($sql) or die(mysql_error());


echo "<h1>you have registered sucessfully</h1>";

echo "<a href='login.php'>go to login page</a>";

}
else
{
echo "Please fill in <b>all</b>fields!";
}
}
}
?>

any error in this code?????
if i submit the form im not getting any msg....
danielbala
Forum Newbie
Posts: 9
Joined: Tue Jan 24, 2012 4:27 pm

Re: registration form validation error..

Post by danielbala »

anyone to help me..its very urgent
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: registration form validation error..

Post by social_experiment »

Code: Select all

<?php
if($submit)
{
  if($fullname&&$username&&$password&&$email&&$emp_role)
  {


  $sql="INSERT INTO `logindetails` (fullname,username, password, email, emp_role,$date) VALUES ('$fullname',$username',     '$password','$email','$emp_role','$date')";
$result=mysql_query($sql) or die(mysql_error());


echo "<h1>you have registered sucessfully</h1>";

echo "<a href='login.php'>go to login page</a>";

}
else
{
echo "Please fill in <b>all</b>fields!";
}
}
// add this
else {
 echo 'Nothing';
}
?>
There is a else statetment missing which is where your script seems to be ending. If this is the case it means $submit is not true
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply