简体   繁体   中英

Form is not working when used with if(isset($_POST("submit")))

My form is not working when used with if(isset($_POST["submit"])) Please help

<form name="form"  onsubmit="return chkEntry()"  action="#" enctype="multipart/form-data"  method="post">
<fieldset>          
    <label for="email">Email:</label>
    <input type="email" id="email" name="ema" />            
    <label for="message">Message:</label>
    <textarea id="message" name="comment"></textarea>
    <input type="text"  style="visibility:hidden" name="tut" value="<?php echo $tu?> "/>
    <input type="text"  style="visibility:hidden" name="file" value="<?php echo $fi?> "/>
    <input type="text"  style="visibility:hidden" name="file" value="<?php echo $fi?> "/>
    <input type="submit" name="enter" value="Submit" align="right"/></p> </div>
</fieldset>       

$_POST is an array , not a function name. So it should be $_POST[KEY] . And as key you use input's name , not value as you tried. Not to mention you should type it correctly - you probably wanted submit but ended in sumit . But it should be enter anyway ;). So if you want to check if submit button was hit, then you should do

if( isset( $_POST['enter'] ) ) {
   // form submitted
}

您的提交按钮被命名为submit ,当您寻找要发布的sunmit

Right now, there's nothing associated to $_POST("sunmit") which is a wrong syntax by the way. If you had an element called sunmit , you would access it using $_POST['sunmit'] .

Try print_r($_POST) to see all variables that are being passed from the form to the PHP file.

而不是使用if(isset($_POST("sunmit")))使用if(isset($_POST("enter")))作为提交按钮的名称是enter

you dont have a sunmit button , so this one wont work '$_POST("sunmit")'.

. Please use the follwoing to get form to be submitted:

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

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM