1
My project registers users and in the database I have a table User and another Profile. To User is for data from login and password, and the Profile for personal data. But now I need to create a new type of Profile, getting ProfileEmpresa and ProfileCliente. On the registration form you have input hidden saying what kind of profile (1 or 0), to direct the data to the right table.
The problem: in class Registrationcontrollerextention I can’t get the 'type' value and make a if/else within the method construct.
UPDATE: I was able to solve this problem, but even recording correctly in the comic shows an error on the page. Notice: Undefined variable: tipo in C: xampp htdocs festas controllers authenticate registrationcontrollerextention.php on line 24
class Registrationcontrollerextention{
private $registry;
private $extraFields = array();
private $errors = array();
private $submittedValues = array();
private $sanitizedValues = array();
private $errorLabels = array();
private $tipo;
public function __construct($registry )
{
if(isset($_POST['register_tipo']))
{
$tipo = $_POST['register_tipo'];
echo $tipo;
}
/* essa eh a linha 24 */
if($tipo == 0)
{
$this->registry = $registry;
$this->extraFields['dino_name'] = array( 'friendlyname' => 'Pet Dinosaurs Name', 'table' => 'profileCliente', 'field' => 'dino_name', 'type' => 'text', 'required' => false );
$this->extraFields['dino_breed'] = array( 'friendlyname' => 'Pet Dinosaurs Breed', 'table' => 'profileCliente', 'field' => 'dino_breed', 'type' => 'text', 'required' => false );
$this->extraFields['dino_gender'] = array( 'friendlyname' => 'Pet Dinosaurs Gender', 'table' => 'profileCliente', 'field' => 'dino_gender', 'type' => 'text', 'required' => false);
$this->extraFields['dino_dob'] = array( 'friendlyname' => 'Pet Dinosaurs Date of Birth', 'table' => 'profileCliente', 'field' => 'dino_dob', 'type' => 'DOB', 'required' => false );
}
else
{
$this->registry = $registry;
$this->extraFields['dino_name'] = array( 'friendlyname' => 'Pet Dinosaurs Name', 'table' => 'profileEmpresa', 'field' => 'dino_name', 'type' => 'text', 'required' => false );
$this->extraFields['dino_breed'] = array( 'friendlyname' => 'Pet Dinosaurs Breed', 'table' => 'profileEmpresa', 'field' => 'dino_breed', 'type' => 'text', 'required' => false );
$this->extraFields['dino_gender'] = array( 'friendlyname' => 'Pet Dinosaurs Gender', 'table' => 'profileEmpresa', 'field' => 'dino_gender', 'type' => 'text', 'required' => false);
$this->extraFields['dino_dob'] = array( 'friendlyname' => 'Pet Dinosaurs Date of Birth', 'table' => 'profileEmpresa', 'field' => 'dino_dob', 'type' => 'DOB', 'required' => false );
}
}
This is my form
<form action="authenticate/register" method="post" class="form-horizontal" role="form">
<input type="text" class="form-control" id="register_user" name="register_user" value="{register_user}" >
<input type="password" class="form-control" id="register_password" name="register_password" value="" >
<input type="password" class="form-control" id="register_password_confirm" name="register_password_confirm" value="" >
<input type="text" id="register_email" name="register_email" value="{register_email}" class="form-control" />
<input type="text" id="register_dino_name" name="register_dino_name" value="{register_dino_name}" class="form-control"/>
<input type="text" id="register_dino_breed" name="register_dino_breed" value="{register_dino_breed}" class="form-control" /><br />
<input type="text" id="register_dino_dob" name="register_dino_dob" value="{register_dino_dob}" class="form-control"/>
<input type="submit" id="process_registration" name="process_registration" value="Enviar!" class="botao"/>
<input type="hidden" id="register_tipo" name="register_tipo" value="1"/>
</form>
puts the source of your form also so we can analyze better
– luigibertaco
I managed to. Thank you!!
– Rachel
@Rachel, I’m glad you solved it. If it was with any response, you can check, otherwise you can describe the solution to anyone who might have the same problem as you.
– Papa Charlie