🔒 Closed Patulong sa magaling sa OOP sa PHP

Status
Not open for further replies.

dev-ace

Forum Expert
Patulong sana ako regarding sa OOP PHP
ayaw kase lumabas dito sa ui yung validation error :/ pero gumagana naman sya kapag na i vavar dump ko .. patulong naman mag tatatlong oras nako kaka debug .

[CODE title="controller.php"]<?php
session_start();
$errors = array();
function registerUser () {



if(isset($_POST['register'])) {


$name = htmlentities($_POST['name']);
$email = htmlentities($_POST['email']);
$address = htmlentities($_POST['address']);
$phone = htmlentities($_POST['phone']);
$password = htmlentities($_POST['password']);
// $password2 = htmlentities($_POST['password2']);


if(empty($name)) {
$errors['name'] = "Name is required";
}


if(empty($email)) {
$errors['email'] = "Email is required";
}

if(empty($address)) {
$errors['address'] = "address is required";
}


if(empty($phone)) {
$errors['phone'] = "phone is required";
}


if(empty($password)) {
$errors['password'] = "password is required";
}

if(!array_filter($errors)) {

$create = new createUser($name,$email,$address,$phone,$password);


if($create->createUser()) {

// $registered_id = $create->insert_id;
// $_SESSION['id'] = $registered_id;
// $_SESSION['name'] = $name;
// $_SESSION['email'] = $email;



// echo "<script>alert('Registered Successfuly')
// window.location='mydashboard.php';
// </script>";



}else {
// var_dump($create);
echo 'DB ERROR';
}

} // else {

// var_dump($errors);

// }

}




}



?>[/CODE]


[CODE title="header.php"]
<form action="" method="POST">
<?php
registerUser();
if($errors): ?>
<?php foreach($errors as $error): ?>
<div class="alert text-danger"><?= $error?></div>
<?php endforeach; ?>
<?php endif ?>

<div class="form-group">
<label for="username">Name</label>
<input type="text" class="form-control" name="name" >

</div>
<div class="form-group">
<label for="username">Email</label>
<input type="email" class="form-control" name="email" >

</div>
<div class="form-group">
<label for="username">Address</label>
<input type="text" class="form-control" name="address" >
</div>
<div class="form-group">
<label for="username">Phone</label>
<input type="text" class="form-control" name="phone" >
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" name="password" >
</div>
<!-- <div class="form-group">
<label for="password">Confirm Password</label>
<input type="password" class="form-control" name="password2" >
</div> -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<input type="submit" class="btn btn-primary" name="register" value="Register">
</div>
</form>
</div>
</div>
</div>[/CODE]


Gusto ko sana ganito lumabas napapalabas ko naman sya kapag procedural .. ganto lumalabas kapag procedural po ..
1606904913406.webp


ganto naman kapag naka OOP ayaw lumbas blanko lang ;;/

1606904944091.webp


ganto naman kapag naka var_dump .
1606904995818.webp


sana may maka tulong ..... godbless
 
mukhang magkaiba yong button mo dun sa unang pic kasi signup sya and to the next pic register na....
 
Status
Not open for further replies.

About this Thread

  • 2
    Replies
  • 396
    Views
  • 2
    Participants
Last reply from:
joker09

Online now

Members online
920
Guests online
3,237
Total visitors
4,157

Forum statistics

Threads
2,276,129
Posts
28,967,781
Members
1,231,127
Latest member
zrhu
Back
Top