Pano to ma fix

loktoy

Established
once po na lumabas na po yun error message ko na "payee name is required o kaya Payee name is taken" ngayon mag lalagay ako ng bagong pangalan walang kaparehas sa database pero yun email is meron na kaparehas sa database ngaun mag eerror yun email kasi meron na kaparehas mag message na "email is Already taken" ngayon problima ko is bigla nawawala yun input field ng payee name.. sa sumunod saknya input field..

if(isset($_SESSION["errors_signup"]) && isset($_SESSION["signup_error"]['payeename']))
{
$error = $_SESSION["errors_signup"];
foreach($error as $errors => $value)
{
if( $errors == 'payeename' || $errors == 'payeename_taken')
{
echo '<div class="form-group mt-1 ">';
echo '<label for="PayeeName">Payee Name:</label> <small id="emailHelp" class="form-text text-muted"> Note: Registered your name base on your account</small>';
echo '<input type="text" class="form-control form-control-sm rounded-3" name="payeename" value="' . $_SESSION["signup_error"]['payeename'] . '" id="pname" placeholder="" >';
echo '<div class="error">' . $value .'</div>';
echo '</div>';

}

}

}else
{
echo '<div class="form-group mt-1 ">';
echo '<label for="PayeeName">Payee Name:</label> <small id="emailHelp" class="form-text text-muted"> Note: Registered your name base on your account</small>';
echo '<input type="text" class="form-control form-control-sm rounded-3" name="payeename" value="' . '" id="pname" placeholder="" >';
echo '</div>';
}

error messge
if(empty($dbPayeeName)){
$error['payeename'] = "Payee name is required";
}elseif (is_payeename_taken ($conn, $dbPayeeName )){
$error["payeename_taken"] = "Payee Name Already taken";
}
 
Based on the code you provided, it seems like the issue is with how you handle error messages for the payee name and email fields.

Currently, if the payee name is required or already taken, the corresponding error message is displayed correctly. However, if the email is already taken, the payee name input field disappears.

To fix this issue, you can modify the code as follows:

PHP:
if (isset($_SESSION["errors_signup"]) && isset($_SESSION["signup_error"]['payeename'])) {
    $error = $_SESSION["errors_signup"];
    foreach ($error as $errors => $value) {
        if ($errors == 'payeename' || $errors == 'payeename_taken') {
            echo '<div class="form-group mt-1 ">';
            echo '<label for="PayeeName">Payee Name:</label> <small id="emailHelp" class="form-text text-muted">  Note: Registered your name based on your account</small>';
            echo '<input type="text" class="form-control form-control-sm rounded-3" name="payeename" value="' . $_SESSION["signup_error"]['payeename'] . '" id="pname" placeholder="" >';
            echo '<div class="error">' . $value .'</div>';
            echo '</div>';
        }
    }
} else {
    echo '<div class="form-group mt-1 ">';
    echo '<label for="PayeeName">Payee Name:</label> <small id="emailHelp" class="form-text text-muted">  Note: Registered your name based on your account</small>';
    echo '<input type="text" class="form-control form-control-sm rounded-3" name="payeename" value="' . (isset($_SESSION["signup_error"]['payeename']) ? $_SESSION["signup_error"]['payeename'] : '') . '" id="pname" placeholder="" >';
    echo '</div>';
}

if (isset($_SESSION["errors_signup"]) && isset($_SESSION["signup_error"]['email'])) {
    $error = $_SESSION["errors_signup"];
    foreach ($error as $errors => $value) {
        if ($errors == 'email' || $errors == 'email_taken') {
            echo '<div class="form-group mt-1 ">';
            echo '<label for="Email">Email:</label>';
            echo '<input type="email" class="form-control form-control-sm rounded-3" name="email" value="' . $_SESSION["signup_error"]['email'] . '" id="email" placeholder="" >';
            echo '<div class="error">' . $value .'</div>';
            echo '</div>';
        }
    }
} else {
    echo '<div class="form-group mt-1 ">';
    echo '<label for="Email">Email:</label>';
    echo '<input type="email" class="form-control form-control-sm rounded-3" name="email" value="' . (isset($_SESSION["signup_error"]['email']) ? $_SESSION["signup_error"]['email'] : '') . '" id="email" placeholder="" >';
    echo '</div>';
}

By adding another section for displaying the error message and input field for the email, you can ensure that both the payee name and email fields are handled correctly.
 
Based on the code you provided, it seems like the issue is with how you handle error messages for the payee name and email fields.

Currently, if the payee name is required or already taken, the corresponding error message is displayed correctly. However, if the email is already taken, the payee name input field disappears.

To fix this issue, you can modify the code as follows:

PHP:
if (isset($_SESSION["errors_signup"]) && isset($_SESSION["signup_error"]['payeename'])) {
    $error = $_SESSION["errors_signup"];
    foreach ($error as $errors => $value) {
        if ($errors == 'payeename' || $errors == 'payeename_taken') {
            echo '<div class="form-group mt-1 ">';
            echo '<label for="PayeeName">Payee Name:</label> <small id="emailHelp" class="form-text text-muted">  Note: Registered your name based on your account</small>';
            echo '<input type="text" class="form-control form-control-sm rounded-3" name="payeename" value="' . $_SESSION["signup_error"]['payeename'] . '" id="pname" placeholder="" >';
            echo '<div class="error">' . $value .'</div>';
            echo '</div>';
        }
    }
} else {
    echo '<div class="form-group mt-1 ">';
    echo '<label for="PayeeName">Payee Name:</label> <small id="emailHelp" class="form-text text-muted">  Note: Registered your name based on your account</small>';
    echo '<input type="text" class="form-control form-control-sm rounded-3" name="payeename" value="' . (isset($_SESSION["signup_error"]['payeename']) ? $_SESSION["signup_error"]['payeename'] : '') . '" id="pname" placeholder="" >';
    echo '</div>';
}

if (isset($_SESSION["errors_signup"]) && isset($_SESSION["signup_error"]['email'])) {
    $error = $_SESSION["errors_signup"];
    foreach ($error as $errors => $value) {
        if ($errors == 'email' || $errors == 'email_taken') {
            echo '<div class="form-group mt-1 ">';
            echo '<label for="Email">Email:</label>';
            echo '<input type="email" class="form-control form-control-sm rounded-3" name="email" value="' . $_SESSION["signup_error"]['email'] . '" id="email" placeholder="" >';
            echo '<div class="error">' . $value .'</div>';
            echo '</div>';
        }
    }
} else {
    echo '<div class="form-group mt-1 ">';
    echo '<label for="Email">Email:</label>';
    echo '<input type="email" class="form-control form-control-sm rounded-3" name="email" value="' . (isset($_SESSION["signup_error"]['email']) ? $_SESSION["signup_error"]['email'] : '') . '" id="email" placeholder="" >';
    echo '</div>';
}

By adding another section for displaying the error message and input field for the email, you can ensure that both the payee name and email fields are handled correctly.
wala pa rin ganun pa rin
 
wala pa rin ganun pa rin
Apologies for the confusion. It seems that the issue is not with the code provided, but with some other part of your code or logic.

Here are a few suggestions to troubleshoot the issue:

1. Check the session variables: Make sure that the session variables $_SESSION["errors_signup"] and $_SESSION["signup_error"]['payeename'] are properly set when the payee name is required or already taken. Also, check the session variables for the email field.

2. Debug the code: Add some debug statements to check the values of the session variables and the flow of your code. For example, you can use var_dump($_SESSION["errors_signup"]) and var_dump($_SESSION["signup_error"]) to see their values.

3. Check the condition for displaying the payee name field: Verify that the condition if ($errors == 'payeename' || $errors == 'payeename_taken') is being satisfied when the payee name error occurs.

4. Check the condition for displaying the email field: Verify that the condition if ($errors == 'email' || $errors == 'email_taken') is being satisfied when the email error occurs.

5. Check for any other code that might be modifying the form fields or session variables related to the payee name and email.

By carefully reviewing and debugging your code, you should be able to identify the issue and fix it accordingly.
 

About this Thread

  • 3
    Replies
  • 337
    Views
  • 1
    Participants
Last reply from:
Unknown user

Trending Topics

Online now

Members online
1,018
Guests online
1,110
Total visitors
2,128

Forum statistics

Threads
2,274,482
Posts
28,956,132
Members
1,234,247
Latest member
Makabulbol11
Back
Top