how to access another php file from a form ?

前端 未结 1 1134
悲哀的现实
悲哀的现实 2021-01-26 07:20

I\'m doing the form validation using php.I\'m trying to access the php file from my form(

).But it shows me undefined variable err
相关标签:
1条回答
  • 2021-01-26 07:51

    You can try a different approach:

    Make all the fields required in html.

    <input type="text" name="fname" value="<?php echo $fname;?>" required> 
    

    Then on the php do this. Define the variable outside the if-else sections.:

    $fname = '';
    
    if (empty($_POST["fname"]))
     {$error['fname']= "First Name is required";}
     else
     {
     $fname = test_input($_POST["fname"]);
    }
    
    0 讨论(0)
提交回复
热议问题