Using PHP to get user input via checkbox through a database
| From: | Wil Hitchman | Date: | Tue, 26 Jul 2005 15:37:39 +0000 |
| Subject: | Using PHP to get user input via checkbox through a database | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-219364@lists.php.net to get a copy of this message | ||
Hello everyone,
What I want to do is have a form (which is already created) where the user selects (via checkbox) on
an item or group of items (almost like a shopping cart). These items are stored in a MySql database
and the program was written in PHP. So far I have created an insert form that inserts the products
into a database. The database is displayed in a form where the user now needs to click on the
select box so that he/she can choose their items. Once they have chosen the items a confirmation
page is supposed to come out with the user's choices and the user will confirm that this is
correct or not and either click submit or go back to choose again. If they click submit than I am
supposed to receive an email with all of the user's choices. The part I am still stuck in is
when the user attempts to choose, nothing really happens. Following is the code that displays the
database and allows the user to choose via the check box....Any help would be appreciated.
<?php require_once('Connections/connBlog.php'); ?>
<?php
mysql_select_db($database_connBlog, $connBlog);
$query_Recordset1 = "SELECT * FROM ebay_products";
$Recordset1 = mysql_query($query_Recordset1, $connBlog) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<?php require_once('Connections/connBlog.php'); ?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div align="center">
<p> </p>
<form action="" method="post" name="form1">
<table width="75%" height="10%" border="10"
align="center" cellpadding="0" cellspacing="0"
bordercolor="#99FFCC">
<tr>
<td><div align="center">Description of Product</div></td>
<td><div align="center">Coupon Amount</div></td>
<td><div align="center">Expiration Date</div></td>
<td><div align="center">Your Selection</div></td>
</tr>
<?php do { ?>
<tr>
<td width="65%">
<div align="center"><?php echo $row_Recordset1['product'];
?></div></td>
<td width="8%">
<div align="center">$<?php echo $row_Recordset1['discount'];
?></div></td>
<td width="15%">
<div align="center"><?php echo $row_Recordset1['expire'];
?></div></td>
<td width="2%">
<div align="center">
<input name="select" type="checkbox" id="select"
value="checkbox">
</div></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<table width="25%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td>
<div align="center">
<input type="submit" name="Submit" value="Submit">
</div></td>
<td>
<div align="center">
<input name="back" type="button" id="back"
value="Go Back">
</div></td>
</tr>
</table>
<p> </p>
</form>
<p> </p>
</div>
<p align="center"> <a href="ebayinsert.php">Insert
Data</a></p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>