Search the Community
Showing results for tags 'checkbox & form submittion'.
-
Hi ! I am created this form - well it's more of a view and less of a form since the form part is only the check-boxes column and the rest is the data displayed from a database. But now I want to have this submitted with a SUBMIT button centered beneath the form after I have checked the required check boxes. I am unable to find a way to do this maybe simple task. Please help, unclubbed.php <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $db = 'testdb'; // CHANGE THIS TO ANY EXISTING DB ON PHPMYADMIN OR CREATE THIS DB FIRST IN PHPMYADMIN // $fcon = mysqli_connect($dbhost, $dbuser, $dbpass, $db); if(!$fcon ) { die('Could not connect: ' . mysql_error()); } // echo 'Connected successfully'; /* /////////// UNCOMMENT TO CREATE A TABLE IN A DATABASE NAMED testdb THEN COMMENT BACK ///////////// $sql = "CREATE TABLE member( mid INT NOT NULL AUTO_INCREMENT, name VARCHAR(20) NOT NULL, reg_date Date NOT NULL, email VARCHAR(30) NOT NULL, cell INT NOT NULL, status VARCHAR(2) NOT NULL, primary key ( mid ))"; if (mysqli_query($fcon,$sql)) { echo "Table member created successfully"; } else { echo "Error creating table: " . mysqli_error($con); } $query = "Insert into member (name, reg_date, email, status) VALUES ('John','1980-08-12','john@123.com','9878954323','cc')"; mysqli_query($fcon, $query); $query = "Insert into member (name, reg_date, email, status) VALUES ('Bill','1988-03-21','bill@123.com','9878900123','cc')"; mysqli_query($fcon, $query); $query = "Insert into member (name, reg_date, email, status) VALUES ('Jack','1990-05-18','jack@123.com','9878912300','cc')"; mysqli_query($fcon, $query); */ $check = true; $query = "SELECT * from member"; $result = mysqli_query($fcon, $query); if(isset($_POST['submit']) && $_POST['submit'] == 'Submit') { echo "<br> Member = ".$_POST['name']."<br>" ; echo "RegDate = ".$_POST['reg_date']."<br>" ; echo "Email = ".$_POST['email']."<br>" ; echo "Status = ".$_POST['status']."<br>" ; /// more code would go here once I have submitted the check box information successfully ///// } ?> <html> <head> <title> CLUB ADMIN </title></head> <body> <table> <?php echo "<table class = 'TFtable' border = 1 cellspacing =2 cellpadding = 5 >"; echo "<tr>"; echo "<th> S.No. </th>"; echo "<th> Member </th>"; echo "<th> Reg Date </th>"; echo "<th> Email </th>"; if($check == true) echo "<th> <Input type='checkbox' id='selecctall' /> All </th>"; else echo "<th> Status </th>"; echo "</tr>"; $cnt = 1; while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $name = htmlspecialchars($row['name']); $reg_date = htmlspecialchars($row['reg_date']); $cell = htmlspecialchars($row['cell']); $email = htmlspecialchars($row['email']); $mid = htmlspecialchars($row['mid']); if($check == false) $status = htmlspecialchars($row['status']); echo "<tr>"; echo "<td>".$cnt++."</td>"; echo "<td>".$name."</td>"; echo "<td>".$reg_date. "</td>"; echo "<td>".$email. "</td>"; if($check == true) { echo "<form name = 'form1' action='unclubbed.php' method='post' > "; echo "<td align ='center'><Input type='hidden' name='mid' value=$mid> <Input class='checkbox1' type = 'checkbox' name='check[]' value='$mid'> </td>"; echo "</form>"; echo "</tr>"; } else echo "<td>".$status. "</td> </tr> "; } ?> </table> </body> </html> Thanks !