Change required fields in php contact form

Discussion in 'HTML & Website Design' started by jess888, Jan 29, 2023.

  1. #1
    I want to change my php form so that only the email address is required.

    I think these might be the areas to change:

    // Validate form fields
    if(empty($email) || filter_var($email, FILTER_VALIDATE_EMAIL) === false){
    $valErr .= 'Please enter a valid email.<br/>';
    }
    
    if(empty($valErr)){
    PHP:
    
    
    <!-- Status message -->
    <?php if(!empty($statusMsg)){ ?>
    <div class="status-msg <?php echo $status; ?>"><?php echo $statusMsg; ?></div>
    <?php } ?>
    
    <!-- Form fields -->
    <div class="form-input" style="display:flex; flex-direction: row; justify-content: space-between; align-items: center">
    <label for="Name">name&nbsp;&nbsp;&nbsp;</label>
    <input type="text" name="name" value="<?php echo !empty($postData['name'])?$postData['name']:''; ?>">
    </div>
    PHP:
    Thanks much!
     
    jess888, Jan 29, 2023 IP