0

hi m trying to make a registeration form. i have made it and trying to validate it. m new comer so dont have much knowlege so having problems in validating form.
i have three files one is registeration form. other is geting value from form and storing it in database and third is validating it. but some how my third page has some eror and its not validating. tell me wat to do

// registeration

<html>
<head>

<title>Home Page</title>

</head>
<body bgcolor="#C0DFFD">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr bgcolor="#3366CC">
    <td colspan="3" rowspan="2"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_travel_photo.jpg" alt="Header image" width="242" height="127" border="0" /></td>
    <td height="100" colspan="3" align="center" valign="bottom" nowrap="nowrap" id="logo"><span class="style1">Production Rejection Assessment System </span></td>
    <td width="5">&nbsp;</td>
  </tr>

  <tr bgcolor="#3366CC">
    <td height="60" colspan="3" id="tagline" valign="top" align="center">&nbsp;</td>
	<td width="5">&nbsp;</td>
  </tr>

  <tr>
    <td colspan="7" bgcolor="#003366"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
  </tr>

  <tr bgcolor="#CCFF99">
  	<td colspan="7" id="dateformat" height="25">&nbsp;&nbsp;<script language="JavaScript" type="text/javascript">
      document.write(TODAY);	</script>	</td>
  </tr>
 <tr>
    <td colspan="7" bgcolor="#003366"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
  </tr>

 <tr>
    <td width="183" valign="top" bgcolor="#E6F3FF">
	<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
        <tr>
          <td width="165">&nbsp;<br />
		 &nbsp;<br /></td>
        </tr>
        <tr>
          <td width="165"><a href="javascript:;" class="navText">Home Page </a></td>
        </tr>
        <tr>
          <td width="165"><a href="javascript:;" class="navText">Products</a></td>
        </tr>
        <tr>
          <td width="165"><a href="javascript:;" class="navText">Sign In </a></td>
        </tr>
        <tr>
          <td width="165"><a href="javascript:;" class="navText">About us </a></td>
        </tr>
        <tr>
          <td width="165"><a href="javascript:;" class="navText">FAQ</a></td>
        </tr>
      </table>
 	 <br />
  	&nbsp;<br />
  	&nbsp;<br />
  	&nbsp;<br /> 	</td>
    <td width="56"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="50" height="1" border="0" /></td>
    <td colspan="2" valign="top"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="305" height="1" border="0" /><br />
	&nbsp;<br />
	&nbsp;<br />
	<table border="0" cellspacing="0" cellpadding="0" width="529">
        <tr>
          <td width="529" height="39" class="pageName"><h1 align="center" class="style1">REGISTRATION</h1></td>
		</tr>

		<tr>
          <td height="319" class="bodyText"><form id="" name="registeration" method="post" action="get_user_data.php">
            <p>&nbsp;</p>
            <p>Please fill the following :</p>
            <p>&nbsp; </p>
            <p>Name of Company:            
              <input type="text" name="company_name" />
            </p>
           
            <p>Username:  
              <input type="text" name="username" />
            </p>
            <p>Password :
              <input type="password" name="password" />
            </p>
            <p>Repeat Password : 
              <input type="password" name="repeat_pass" />
            </p>
            <p>Address :
               <input name="address" type="text" />
            </p>
            <p>Phone num : 
              <input type="text" name="phone_num" />
            </p>
            <p>Email:
              <label>
              <input type="text" name="email" />
              </label>
            </p>
            <p>
              <input type="submit" name="Submit" value="Submit" />
              <input type="reset" name="Submit2" value="Reset" />
            </p>
            <p>&nbsp;</p>
          </form>          <p>&nbsp;</p>		</td>
        </tr>
		<tr>
		  <td height="319" class="bodyText">&nbsp;</td>
	    </tr>
      </table>
	   <br />	  </td>
    <td width="57"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="50" height="1" border="0" /></td>
        <td width="190" valign="top"><br />
		&nbsp;<br />
		<table border="0" cellspacing="0" cellpadding="0" width="190">
			<tr>
			<td colspan="3" class="subHeader" align="center">NEW DESTINATIONS</td>
			</tr>

			<tr>
			<td width="40"><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_spacer.gif" alt="" width="40" height="1" border="0" /></td>
			<td width="110" id="sidebar" class="smallText"><img src="../../../Users/dfff/Documents/Unnamed Site 3/a.jpg" alt="Image 1" width="110" height="110" vspace="6" border="0" /><br />
			<p><br />
			To check the orders.<br />
			<a href="javascript:;">Click here &gt;</a></p>

			<p><img src="../../../Users/dfff/Documents/Unnamed Site 3/mm_travel_photo2.jpg" alt="Image 2" width="110" height="110" vspace="6" border="0" /><br />
			To see the reports.<br />
			<a href="javascript:;">Click here  &gt;</a></p>
			 <br />
			&nbsp;<br />
			&nbsp;<br />			</td>
			<td width="40">&nbsp;</td>
			</tr>
	</table>	</td>
	<td width="5">&nbsp;</td>
  </tr>
  <tr>
    <td width="183">&nbsp;</td>
    <td width="56">&nbsp;</td>
    <td width="4">&nbsp;</td>
    <td width="617">&nbsp;</td>
    <td width="57">&nbsp;</td>
    <td width="190">&nbsp;</td>
	<td width="5">&nbsp;</td>
  </tr>

</table>
</script>

</body>
</html>

its working fine

//get_user data

<?php


session_start();	

 //Array to store validation errors
  $errorMsgArray = array();

  //Validation error flag
  $errorFlag = false;
  
  
 $con=mysql_connect("localhost","root","");
	
	mysql_select_db("pras");


function mysql_fix_string($string)
{	
	if (get_magic_quotes_gpc()) 
	$string = stripslashes($string);
	return mysql_real_escape_string($string);
}


	
$name=$_POST['company_name'];
$username=$_POST['username'];
$password=$_POST['password'];
$rep_password=$_POST['repeat_pass'];
$adress=$_POST['address'];
$num=$_POST['phone_num'];
$emal=$_POST['email'];


if ($name=="")
{
$errorMsgArray[]="name is mising";
$errorFlag=true;
}

if ($username=="")
{
$errorMsgArray[]="username is mising";
$errorFlag=true;
}

if ($password=="")
{
$errorMsgArray[]="u havenot entered password";
$errorFlag=true;
}

if ($rep_password=="")
{
$errorMsgArray[]="please enter ur password again";
$errorFlag=true;
}

if ($num=="")
{
$errorMsgArray[]="please enter your number";
$errorFlag=true;
}

if ($emal=="")
{
$errorMsgArray[]="Please enter your email";
$errarFlag=true;
}

if($adress=="")
{
$errorMsgArray[]="pleae enter your address";
$errorFlag=true;
}

if (strcmp($password, $rep_password)!=0)
{
$errorMsgArray[]="both passwords donot match";
$errorFlag=true;
}


//If there are input validations, redirect back to the registration form
  if($errorFlag) {
    $_SESSION['ERROR_MSG_ARRAY'] = $errorMsgArray;
    session_write_close();
    header("location: errors.php");
    exit();
  }


$query = "INSERT INTO customer (name, username, Contact_number,address, Email, password) VALUES  ( '$name' , '$username' , '$num' , '$adress' , '$emal' , '$password')";

$result=mysql_query($query);
if (!$result) die ("Database access failed: " . mysql_error());

else
{
echo "Your record has been successfully added <br> <br>";
echo "<a href=\"registration.php\"> Click to add another record</a>";
}
mysql_close($con);



?>

//errors files for validating

<?php

if ($name=="")
{
echo "name is missing";
}

if ($username=="")
{
echo"username is mising";

}

if ($password=="")
{
echo "u havenot entered password";
}

if ($rep_password=="")
{
echo "please enter ur password again";
}

if ($num=="")
{
echo "please enter your number";
}

if ($emal=="")
{
echo"Please enter your email";
}

if($adress=="")
{
echo "pleae enter your address";
}

if (strcmp($password, $rep_password)!=0)
{
echo "both passwords donot match";

}

this is not working plz help me

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Zagal
0

Hi,
you just redirect to errors.php but you don't send data there. So in "get_user data" under code where you set variables add something like this:

$_SESSION['name'] = $name;
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
$_SESSION['rep_password'] = $rep_password;
$_SESSION['adress'] = $adress;
$_SESSION['num'] = $num;
$_SESSION['emal'] = $emal;

So now ur data will be stored in sessions.
Then you have to validate it so at the top of errors.php add something like this:

session_start(); 
$name  =  $_SESSION['name'];	
$username =  $_SESSION['username']; 	
$password =  $_SESSION['password']; 	
$rep_password = $_SESSION['rep_password']; 	
$adress = $_SESSION['adress'];		
$num =  $_SESSION['num'];			
$emal =  $_SESSION['emal'];

And then at the bottom destroy session:

session_destroy();
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.