Sign up page is created by creating php form and saving data to the server and then that information is used for signin process.Form is validated and then data is stored. When we sign in then that information is validated from server that either this user exists or not. Here is code for sign up form

 <form method=”post” id=”moduleDetail”
action=”signup_view.php<?php echo ($isEditing ? “?id=$userId” : “”); ?>”>
<label for=”user_name”>User Name</label>
<input id=”user_name” name=”user_name” type=”text” value=”<?php echo $userDetail[‘user_name’]; ?>”/>
<span id=”user_nameInfo”></span>
<label for=”email”>E-mail</label>
<input id=”email” name=”email” type=”text” value=”<?php echo $userDetail[‘Email’]; ?>”/>
<span id=”emailInfo”></span>
<label for=”password”>Password</label>
<input type=”password” id=”password” name=”password” value=””/>
<span id=”passwordInfo”></span>
<label for=”re_password”>Re-Password</label>
<input type=”password” id=”re_password” name=”re_password” value=””/>
<span id=”re_passwordInfo”></span>
<input id=”add” name=”add” type=”submit” value=”<?php echo ($isEditing ? “Update” : “Add”); ?>”/>

This form code is submitted to server when it is stored in databases.Here is php code that accepts this form values to store in db
//form submitted
$user_name = $_POST[‘user_name’];
$email = $_POST[’email’];
$password = $_POST[‘password’];
$role = $_POST[‘role’];

$arrUser = array(

//update user
//$signUpDal->updateUser($employeeId, $arrEmp, $arrSalary, $arrSuppliers);
//insert employee
$_SESSION[‘user_name’] = $user_name;
header(“Status: 200″);
$path = HOST_PATH.”public/index.php”;
header(“Location: $path”);
InsertUser() is php function that accepts array and passes to mysql query for inserting data in database. Here is mysql query code in insertUser function.
 public function insertUser($arrUser)
//insert users
$affectedRows = $this->conn->insert(‘users’,$arrUser);

if ($affectedRows > 0) {
$userId = $this->conn->getLastInsertId();
return $userId;
else {
throw new Exception(“Could not insert user details”);
insert funtion is generic function that accepts table name and array of parameters that are to be stored in that table.Here is generic insert function code
// todo: add trim function to values
        public function insert($table, $parameters) {

$qry = ‘insert into ‘
. $table
. ‘ (‘;

// build column names
foreach ($parameters as $key => $value) {
$qry .= $key;

if($key != end(array_keys($parameters))){
$qry .= ‘, ‘;

$qry .= ‘) values (‘;

// build values for columns
foreach ($parameters as $key => $value) {
$qry .= ”’ . $value . ”’;

if($key != end(array_keys($parameters))){
$qry .= ‘, ‘;

$qry .= ‘) ‘;

// execute query
$result = $this->executeScaler($qry);

return $result;

Leave a Reply

Your email address will not be published. Required fields are marked *