php - if (isset($_POST['add'])) don't work? -
this question has answer here:
<?php session_start(); include_once 'dbconnect.php'; if (isset($_post['add'])) { $username = ($_post['username']); $phone = ($_post['phone']); $email = ($_post['email']); $password = ($_post['password']); $address = ($_post['address']); $studing = ($_post['studing']); $birthday = ($_post['birthday']); $stage = ($_post['stage']); $college = ($_post['college']); $department = (['department']); if (mysql_query("insert de (username,phone,email,password,address,studing,birthday,stage,college,department) values ('$username','$phonenumber','$email','$password','$address','$studing','$birthday','$stage','$college','$department')")) { ?> <script>alert('success ...');</script> <?php } else { ?> <script>alert('error ...');</script> <?php } } $res = mysql_query("select * users user_id=" . $_session['user']); $userrow = mysql_fetch_array($res); ?> <html> <head><title> welcome</title> <link rel="stylesheet" href="style.css" type="text/css"/> </head> <body> <div id="header"> <div id="left"><label>welcome</label></div> <div id="right"> <div id="content"> hi <?php echo $userrow['username']; ?> <a href="logout.php?logout">sign out</a></div> </div> </div> <table align="left" width="30%" border="0"> <tr> <td>name</td> <td><input type="text" name="usernamr" placeholder="stud name" required/></td> </tr> <tr> <td> phone number</td> <td><input type="text" name="phonenumber" placeholder="phone number" required/></td> </tr> <tr> <td>email</td> <td><input type="text" name="email" placeholder="email of stud" required/></td> </tr> <tr> <td>password</td> <td><input type="text" name="password" placeholder="password of stud" required/></td> </tr> <tr> <td>address</td> <td><input type="text" name="address" placeholder="address" required/></td> </tr> <tr> <td>studing</td> <td><input type="text" name="studing" placeholder="studing" required/></td> </tr> <tr> <td>birthday</td> <td><input type="text" name="birthday" placeholder="birthday" required/></td> </tr> <tr> <td>stage</td> <td><input type="text" name="stage" placeholder="stage" required/></td> </tr> <tr> <td>college</td> <td><input type="text" name="college" placeholder="college" required/></td> </tr> <tr> <td>department</td> <td><input type="text" name="department" placeholder="department" required/></td> </tr> <tr> <td> <button type="submit" name "add">add</button></td> </table> </body> </html>
your button name attribute not set,
<button type="submit" name "add">add</button></td>
make this:
<button type="submit" name="add">add</button></td>
moreover not have form tags around form elements:
<form action="" method="post"> //set action php file //your table goes here </form>
apart that, make sure name attributes identical post array keys.. example:
$username = ($_post['username']);
won't value of following:
<input type="text" name="usernamr" placeholder="stud name" required/>
because name username = usernamr..
Comments
Post a Comment