php - if statment inside isset function not wokring -
i trying validate form using php, using isset function check if submit button has been clicked. when click submit button code inside isset function not execute.
//html <div style="width:800px; margin:0px auto 0px auto;"> <table> <tr> <td width ="60%" valign="top"> <h2>join find friends today</h2> </td> <td width ="40%" valign="top"> <h2>sign below</h2> <form action ="" method"post"> <input type="text" name="fname" size ="25" placeholder="firstname" /><br/><br/> <input type="text" name="lname" size ="25" placeholder="lastname" /><br/><br/> <input type="text" name="username" size ="25" placeholder="username"/><br/><br/> <input type="text" name="email" size ="25" placeholder="email"/><br/><br/> <input type="text" name="email2" size ="25" placeholder="confirm email"/><br/><br/> <input type="text" name="password" size ="25" placeholder="password"/><br/><br/> <input type="text" name="password2" size ="25" placeholder="confirm password"/><br/><br/> <input type="submit" name="reg" value="sign up"> </form> </td> </tr> </table> //php code <?php //declaring variables prevent errors $fn = ""; //first name $ln = ""; //last name $un = ""; //username $em = ""; //email $em2 = ""; //email 2 $pswd = ""; //password $pswd2 = ""; // password 2 $d = ""; // sign date $u_check = ""; // check if username exists $error =""; if (isset($_post['reg'])) { //registration form $fn = strip_tags($_post['fname']); $ln = strip_tags($_post['lname']); $un = strip_tags($_post['username']); $em = strip_tags($_post['email']); $em2 = strip_tags($_post['email2']); $pswd = strip_tags($_post['password']); $pswd2 = strip_tags($_post['password2']); $d = date("y-m-d"); // year - month - day if(empty($fn)){ echo 'empty'; } } ?>
you forgot =
in <form>
tag.
replace
<form action ="" method"post">
with
<form action="" method="post">
and should work.
Comments
Post a Comment