I want to print the checklist array value, here checklist is dynamically created for each row of Food table. How I can do that ? If I click submit no value is submitted I guess so, How to use submit button? In fact where to use ..plz help me
<?php // File: anyco.php
require('anyco_ui.inc.php');
// Create a database connection
$conn = oci_connect('system','123','localhost/orcl');
ui_print_header('FoodItemList');
//session_start();
//$cid=$_SESSION['cid'];
//do_query($conn, 'SELECT Fooditem_ID,Food_item_name,price,day_available,time_available,discount_percentage,start_date,deadline FROM Food_Item');
ui_print_footer(date('Y-m-d H:i:s'));
function do_query($conn, $query)
{
$stid = oci_parse($conn, $query);
$r = oci_execute($stid,OCI_DEFAULT);
print '<table border="1">';
print '<tr>';
print '<td>Food_ID<td>Food_Name<td>Price(tk)<td>Dvailable_day<td>Avaliable_time<td>Discount<td>Dis_start date<td>Dis_finish date<td>selected item<td>quanity';
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS))
{
print '<tr>';
$num=1;
$val="";
foreach ($row as $item)
{
if($num==1)
{
$val = $item;
$num=2;
}
print '<td>'.($item!== null ? htmlentities($item) : ' ').'</td>';
}
//echo$val;
echo '<td><input type="checkbox" name = "invite[]" value="$val>" </td>';
echo '<td><input type="number" name = "name[]" ></td>';
print '</tr>';
}
print '</table>';
}
if(isset($_POST['submit']))
{
if (is_array($_POST['invite']))
{
foreach($_POST['invite'] as $key=>$name)
{
echo $key, '=>', $name,'<br/>';
//Here $key is the array index and $name is the value of the checkbox
}
}
}
?>
<html>
<style>
body
{
background:orange;
}
</style>
<body text="green">
<br><br>
<form method="post">
<?php do_query($conn, 'SELECT Fooditem_ID,Food_item_name,price,day_available,time_available,discount_percentage,start_date,deadline FROM Food_Item'); ?>
<input type ="submit" value="submit" name="submit"><br><br>
</form>
</body>
</html>
Your form doesn't have any inputs inside it because you are calling your function way before you print out the form tags.
This line needs to move to within the form:
do_query($conn, 'SELECT Fooditem_ID,Food_item_name,price,day_available,time_available,discount_percentage,start_date,deadline FROM Food_Item');
So that the code looks like this, and the whole table with its inputs is printed inside the form tags. I also added a name for the submit button:
<form method="post">
<?php do_query($conn, 'SELECT Fooditem_ID,Food_item_name,price,day_available,time_available,discount_percentage,start_date,deadline FROM Food_Item'); ?>
<input type ="submit" value="submit" name="submit"><br><br>
</form>
Finally, when you echo values into your inputs, there are two syntax errors in this line:
echo '<td><input type="checkbox" name = "invite[]" value="$val>" </td>';
You can echo a variable into a string in several ways - here are two. 1) if the variable is between single quotes, PHP will automatically convert the variable to its value. In this case, it's double quotes, so no go. 2) You start your echo command with single quotes, so you can break out of the string with a single quote, concatenate the variable with a period, and then break back in to the string with another single quote, like this:
echo '<td><input type="checkbox" name = "invite[]" value="' . $val . '"> </td>';
Related
I have two tables in database of my users.
First table contains user unique ID, Name, Contact No and other personal information.
Second table contains unique id of user from first table and device information like his first machine number, second machine number and many others also.
My table no 2 structure is..
On the reports page, I am showing all the information in a table form using this
$sql = "SELECT e.* ,d.* FROM emitra_basic As e INNER JOIN emitra_device as d ON d.uid=e.uid";
$result = $conn->query($sql);
if ($result->num_rows>0) {?>
<table ><tr><td> Uid</td><td> Name</td>
<td> Micro Atm</td>.......and all column of both tables </tr>
<?php while($row = $result->fetch_array()) {
echo "<td>". $row['uid']. "</td>";
echo "<td>". wordwrap($row['name'],15,"\n",1). "</td>"; ....and all
} echo "</table>";
It works fine. But I want to show a customised report. It means I want to give check box/radio button for user of tables field. If he select field uses check box then its show only those value which check box/radio button are selected. It likes if user select three check box/radio button like Uid, name, m_atm. It shows only details of three columns from both tables and display table view accordingly these columns.
If I undestand you, to do that you need add to ON d.uid=e.uid" something like this ON d.uid=e.uid" AND Uid=$id AND name=$name And m_atm=$atm, or to add this to where (to where I thinght is not good)
For example
HTML:
<form method="get" action="/a.php">
<input type="checkbox" name="check1" value="text1"/>
<input type="checkbox" name="check2" value="text2"/>
<input id="submit" onclick="f();return false;" type="button" value="ok"/>
</form>
PHP (test.php)
if(isset($_GET['check1'])) $id=" AND Uid='$_GET[check1]'"; //if is checked first
if(isset($_GET['check2'])) $name=" AND name='$_GET[check2]'"; //if is checked second
/* . . . */
$sql = "SELECT e.* ,d.* FROM emitra_basic As e INNER JOIN emitra_device as d ON (d.uid=e.uid $id $name )";
var_dump($sql);
JS:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
function f() {
var url;
var xmlhttp,
url="/text.php?"+$('form').serialize(); //change text.php
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else if (window.ActiveXObject) {
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.open('GET', url, true);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
myfunction(xmlhttp.responseText);
}
}
xmlhttp.send(null);
function myfunction(response) { alert(url+' '+response);
//do something
}
}
</script>
That Php code is simply, but you can use loop and key value to make it look more good
For example you can use <input name=text[]> for all ckeckboxes elements and do this
foreach ($_GET['text'] as $key => $value) {
if($key==0) $key='uid'; else
if($key==1) $key='name'; else
if($key==2) $key='m_atm';
$q.="$key='$value' AND ";
}
$q=substr($q,0,strlen($q)-5);
$sql2 = "SELECT e.* ,d.* FROM emitra_basic As e INNER JOIN emitra_device as d ON (d.uid=e.uid $q )";
var_dump($sql2);
When you want to show table with dynamic column you can use if....else loop if you know exactly the number of columns query retrieve. Similar to your problem I have created 2 tables.First is employee
eId,Name,Address
And Second Is job
jobId,eId,postName,Skill
Query for retrieving data is:
$query="SELECT e.Name,e.Address,j.postName,j.Skill FROM employee AS e INNER JOIN job AS j ON e.eId=j.eId";
For each column there is checkbox
<input type="checkbox" name="chkName"/>
<input type="checkbox" name="chkAddress"/>......for all columns.
GET values will be compared with the respective columns.
To show columns dynamically using checkbox for above query:
$checkArray=array();
if(isset($_GET['chkName']))
$checkArray[0]=1;
else
$checkArray[0]=0;
if(isset($_GET['chkAddress']))
$checkArray[1]=1;
else
$checkArray[1]=0;
if(isset($_GET['chkPost']))
$checkArray[2]=1;
else
$checkArray[2]=0;
if(isset($_GET['chkSkill']))
$checkArray[3]=1;
else
$checkArray[3]=0;
$query="SELECT e.Name,e.Address,j.postName,j.Skill FROM
employee AS e INNER JOIN job AS j ON e.eId=j.eId";
$result = $con->query($sql);
if ($result->num_rows>0) {
?>
<table >
<tr>
<?php
if($checkArray[0]==1){
?>
<td> Name</td>
<?php
}
if($checkArray[1]==1){
?>
<td> Address</td>
<?php
}
if($checkArray[2]==1){
?>
<td> Post</td>
<?php
}
if($checkArray[3]==1){
?>
<td>Skioll</td>
<?php
}
?>
</tr>
<?php
while($row = $result->fetch_array()) {
echo "<tr>";
if($checkArray[0]==1)
{
echo "<td>". $row[0]. "</td>";
}
if($checkArray[1]==1)
{
echo "<td>". $row[1]. "</td>";
}
if($checkArray[2]==1)
{
echo "<td>". $row[2]. "</td>";
}
if($checkArray[3]==1)
{
echo "<td>". $row[3]. "</td>";
}
echo "</tr>";
}
Hope this will help. Create a variable eg: $condition and assign value like
$condition = "";
if($check1) {
$condition = " AND Uid=$id";
}
if($check2) {
$condition = " AND name=$name";
}
and append this $condition variable in your query. you will get dynamic values. To show the result simple method is to use AJAX on checkbox checked.
You can simply use the checkboxes in the following manner in your page
mypage.html
<form>
<input class="form-check" type="checkbox" name="checkName"><label class="form-label">Name</label>
<input class="form-check" type="checkbox" name="checkMicroATM"><label class="form-label">MicroATM</label>
<!--and so on for each field-->
</form>
<div id="dataTable">
<!--Here your table will be displayed-->
</div>
myquerypage.php
if($_POST){
$sql = "SELECT e.* ,d.* FROM emitra_basic As e INNER JOIN emitra_device as d ON d.uid=e.uid";
$result = $conn->query($sql);
$displayColCount=0; // maintain the count of columns to be displayed
$displayCol=array(); // contains the database column names to be displayed on the page
echo '<div id="dataTable">'; // very useful for replacing the content using ajax call if required
echo '<table>';
echo '<tr>';
if(isset($_POST['checkName'])){
$displayCol[$displayColCount++]='name';
echo '<th>Name</th>';
}
if(isset($_POST['checkMicroATM'])){
$displayCol[$displayColCount++]='m_atm';
echo '<th>MicroATM</th>';
}
.
.
// and so on for each column
echo '</tr>';
while($row = $result->fetch_array()) {
echo '<tr>';
$i=0;
while($i< $displayColCount){
echo "<td>". $row[displayCol[i++]]. "</td>";
}
echo '</tr>';
}
echo '</table>';
echo '</div>';
}
you can call the above page using ajax as
$('.form-check').change(function (e) {
var form=this.form;
var formData = $('form').serialize();
$.ajax({
type: 'POST',
url: 'myquerypage.php',
data: formData,
cache: false,
success: function (html)
{
$("#dataTable").html(html);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
});
I hope this helps you.
I think I get your point. The following code can be used in the same file but for obvious reasons it's better to separate them.
what I have done, I have got a list of the checkboxes based on the fields that you've got in the database.
Post these fields and run query to get back data for only these fields that are posted.
After I generate the html code/table regarding the posted fields and the data
<?php
$result = [];
$fields = [];
$dbFields = [];
$sql = "";
$fieldsNameMapping = [
'e.uid' => 'Uid',
'd.block' => 'Blocked',
'd.m_atm' => 'Atm',
'd.uid_name' => 'Name'
];
if (isset($_POST)) {
// build query based on the posted fields
if (isset($_POST['fields']) && !empty($_POST['fields'])) {
$sql = "SELECT ";
foreach ($_POST['fields'] as $fieldValue) {
$sql .= $fieldValue . ", ";
// get field names
$fields[] = $fieldsNameMapping[$fieldValue];
// mapping db field names, remove first two characters
$dbFields[] = substr($fieldValue, 2);
}
// remove last comma
$sql = substr($sql, 0, -2);
$sql .= " FROM emitra_basic As e INNER JOIN emitra_device as d ON d.uid=e.uid";
// get result
$result = $conn->query($sql);
}
}
?>
<form method="post">
<input type="checkbox" name="fields[]" value="e.uid" /> Uid<br />
<input type="checkbox" name="fields[]" value="d.block" /> Blocked<br />
<input type="checkbox" name="fields[]" value="d.m_atm" /> Atm<br />
<input type="checkbox" name="fields[]" value="d.uid_name" /> Name<br />
<input type="submit" value="Show Result" />
</form>
<?php if (!empty($fields)) { ?>
<table>
<thead>
<tr>
<?php foreach($fields as $fieldName) { ?>
<th><?php echo $fieldName ?></th>
<?php } ?>
</tr>
</thead>
<?php if (!empty($result) && $result->num_rows > 0) { ?>
<tbody>
<?php while($row = $result->fetch_array()) { ?>
<tr>
<?php foreach($dbFields as $fieldDbName) { ?>
<td><?php echo $row[$fieldDbName] ?></td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
<?php } ?>
</table>
<?php } ?>
I have this code so far, which reads a simple table with 3 varchar fields:
<?php
//db connection code...
// select database
mysql_select_db($db) or die ("Unable to select database!");
// create query
$query = "SELECT * FROM Sheet1";
// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// see if any rows were returned
if (mysql_num_rows($result) > 0) {
// yes
// see if any rows were returned
if (mysql_num_rows($result) > 0) {
// yes
// print them one after another
echo "<html><body><table cellpadding=10 border=1>";
while($row = mysql_fetch_assoc($result)) {
echo "<tr>";
echo "<td>".$row['stickerID']."</td>";
echo "<td>" .$row['stickerName']."</td>";
echo "<td>".$row['stickerSection']."</td>";
echo "<td>"?>
<form name="some form" action="editform.php" method="post">
<input type="checkbox" name="<?php echo $row['stickerID'] ?>" value=" <?php echo $row['stickerStatus'] ?> ">
<?php "</td>";
echo "</tr>";
}
echo "</table></body></html>";
echo " " ?>
<input type="submit" name="editWish" value="Edit">
</form>
<?php " ";
} else {
// no
// print status message
echo "No rows found!";
}
// free result set memory
mysql_free_result($result);
// close connection
mysql_close($connection);
?>
The database has 4 fields, 3 varchar and 1 int with current value of 0. I checked the page source code and confirmed each checkbox name is the stickerID. Now I will post this to the editform.php which I must create. What Im wondering is how should I write the update sql so that it takes into account each new value selected by the user in the form?
This is my idea, but how to I do it for every checkbox?
editform.php
<?php
//update multiple records
//UPDATE user_items SET stickerStatus = $_POST["stickerStatus"] WHERE stickerID = $_POST["stickerID"];
?>
First question: use mysql_fetch_assoc() instead of mysql_fetch_row(). That will return an associative array instead of an enumerated one.
Second question: read up on HTML forms and form handling.
The answer to the question in the comments:
// The <form> tag should only be echoed once.
echo '<form name="some form" action="editform.php" method="post">';
while($row = mysql_fetch_assoc($result)) {
echo "<tr>";
echo "<td>".$row['stickerID']."</td>";
echo "<td>" .$row['stickerName']."</td>";
echo "<td>".$row['stickerSection']."</td>";
echo "<td>"?>
<input type="hidden" name="status_<?php echo $row['stickerID"; ?>" value="0">
<input type="checkbox" name="status_<?php echo $row['stickerID'] ?>" value="<?php echo $row['stickerStatus'] ?> ">
<?php "</td>";
echo "</tr>";
}
// You need a submit button to send the form
echo '<input type="submit">';
// Close the <form> tag
echo '</form>';
Using a hidden input with the same name as the checkbox makes sure a value for the given input name is sent to the server. The value of a checkbox that's not checked will not be sent. In that case the hidden input will be used.
You can get the submitted values in editform.php as follows:
<?php
foreach ($_POST as $field => $value) {
if (strpos($field, 'status_')) {
// Using (int) makes sure it's cast to an integer, preventing SQL injections
$stickerID = (int) str_replace('status_', '', $field);
// Again, preventing SQL injections. If the status could be a string, then use mysql_real_escape_string()
$stickerStatus = (int) $value;
// Do something with the results
}
}
Do
print_r($row)
to find out exactly how your row arrays are constructed and work from there.
For your comparison operator, use
$row[3] === 0
instead of
$row[3] == 0
This will return true if both the value and data type match rather than just the value.
0 can mean the Boolean false aswell as the numeric value 0
I want to print the check box values(only the selected value) but the following error are shown
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.9
here is the entire php file ... i am new in php ... so plz check my code..there may b some error ...
<?php // File: anyco.php
require('anyco_ui.inc.php');
// Create a database connection
$conn = oci_connect('system','123','localhost/orcl');
ui_print_header('FoodItemList');
//session_start();
//$cid=$_SESSION['cid'];
do_query($conn, 'SELECT Fooditem_ID,Food_item_name,price,day_available,time_available,discount_percentage,start_date,deadline FROM Food_Item');
ui_print_footer(date('Y-m-d H:i:s'));
// Execute query and display results
function do_query($conn, $query)
{
$stid = oci_parse($conn, $query);
$r = oci_execute($stid,OCI_DEFAULT);
print '<table border="1">';
print '<tr>';
print '<td>Food_ID<td>Food_Name<td>Price(tk)<td>Dvailable_day<td>Avaliable_time<td>Discount<td>Dis_start date<td>Dis_finish date<td>selected item<td>quanity';
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS))
{
print '<tr>';
$num=1;
$val="";
foreach ($row as $item)
{
if($num==1)
{
$val = $item;
$num=2;
}
print '<td>'.($item!== null ? htmlentities($item) : ' ').'</td>';
}
echo '<td><input type="checkbox" name="ticked[]" value="$val"></td>';
echo '<td><input type="number" name ="name[]" ></td>';
print '</tr>';
}
print '</table>';
}
if(isset($_POST['submit'])&&)
{
echo'yeeeeeeeeeeeeeeee';
$ticked = $_POST['ticked'];
foreach ($ticked as $ticked=>$value)
{
echo "values selected are : ".$value."<br />";
}
}
?>
<html>
<style>
body
{
background:orange;
}
</style>
<body text="green">
<br><br>
<form action="<?php echo $current_file;?>" method="POST">
<input type ="submit" value="Submit"><br><br>
</form>
</body>
</html>
First thing to do is remove &&
if(isset($_POST['submit'])&&)
^ remove the &&
then change this
<input type ="submit" value="Submit"><br><br>
to
<input type="submit" name="submit" value="Submit"><br><br>
because isset($_POST['submit']) is looking for a name=""
<?php
if(isset($_POST['submit']))
{
echo'yeeeeeeeeeeeeeeee';
// more of your code...
}
?>
Edit
remove
action="<?php echo $current_file;?>"
from
<form action="<?php echo $current_file;?>" method="POST">
so it should be just
<form method="POST">
I've managed to pull records from a mysql database using php with a checkbox to select. I'm struggling to make the selected records (with the checkboxes) appear on a new page. Here is my code so far:
<?php
include('connect.php');
$query = 'SELECT * FROM grades';
if ($r = mysql_query($query)) {
print "<form>
<table>";
while ($row = mysql_fetch_array($r)) {
print
"<tr>
<td>{$row['InstitutionName']}</td>
<td>{$row['InstitutionAddress']}</td>
<td>{$row['SubjectArea']}</td>
<td><input type='checkbox' name='check[$row{['GradeID']}] value='check' /></td>
</tr>";
}
print "</table>
</form>";
$checkbox[] = isset($_POST['checkbox']) ? true : false;
} else {
print '<p style="color: blue">Error!</p>';
}
?>
<html>
<form action="check2.php" method="POST">
<input type='submit' name='Submit' value='Submit'>
</html>
And on the page where I want the selected records to display, I have:
<?php
if(isset($checkbox))
{
foreach($checkbox as $value)
{
echo $value."<br>"; //it will print the value of your checkbox that you checked
}
}
?>
Any assistance would be appreciated!
Put checked="checked" just like you have put value="check":
<td><input type='checkbox' name='check[$row{['GradeID']}] value='check' checked="checked" /></td>
Edit:
Probably I misunderstood you. What do you expect to see?
First, you should make the form to perform POST request instead of GET (default):
print "<form method='POST' action='THE_FILE_YOU_PRINT_RESULTS.php'>"
Then in "THE_FILE_YOU_PRINT_RESULTS.php" do a print_r($_POST); to see what you get and how to display it.
A better way to do this would be to name your checkboxes check[]. Each checkbox value should then be the ID (rather than check).
Then on your results page, just loop through each instance of check[] and print the value out.
check[$row{['GradeID']}]
Seems incorrect to me, should it be:
check[{$row['GradeID']}]
Notice the moved opening curly bracket to before the $
Sorry if this is wrong haven't used PHP in long time but it stood out for me
The are a couple of error in the form print function.
You have to put the action on the first form, not on the second, you have to change the way how you print the checkbox as well.
Try to print the form in this way:
<?php
include('connect.php');
$query = 'SELECT * FROM grades';
if ($r = mysql_query($query)) {
print "
<form action=\"check2.php\" method=\"POST\">
<table>";
while ($row = mysql_fetch_array($r)) {
print
"<tr>
<td>{$row['InstitutionName']}</td>
<td>{$row['InstitutionAddress']}</td>
<td>{$row['SubjectArea']}</td>
<td><input type='checkbox' name='check[".$row['GradeID']."] value='".$row['GradeID']."' /></td>
</tr>";
}
print "</table>
<input type='submit' name='Submit' value='Submit'>
</form>";
$checkbox[] = isset($_POST['checkbox']) ? true : false;
} else {
print '<p style="color: blue">Error!</p>';
}
?>
And print the checked box reading the _REQUEST array:
<?php
if(isset($_REQUEST["check"]))
{
foreach($_REQUEST["check"] as $key=>$value)
{
echo $key."<br>"; //it will print the value of your checkbox that you checked
}
}
?>
This should work.
I'm trying to make a small survey that populates the selections for the dropdown menu from a list of names from a database. The survey does this properly. I want to submit the quote the user submits with this name into a quote database. The quote text they enter into the field goes in properly, however, the name selected from the menu does not get passed in. Instead I get a blank name field.
I understand some of my code is out of context, but the name is the only thing that does not get passed in properly.
On form submit, I include the php file that submits this data to the database:
<form action="<?php $name = $_POST['name']; include "formsubmit.php";?>" method="post">
<label> <br />What did they say?: <br />
<textarea name="quotetext" rows="10" cols="26"></textarea></label>
<input type="submit" value="Submit!" />
</form>
The variable $name comes from this (which populates my dropdown menu):
echo "<select name='name'>";
while ($temp = mysql_fetch_assoc($query)) {
echo "<option>".htmlspecialchars($temp['name'])."</option>";
}
echo "</select>";
And here is my formsubmit.php:
<?php:
mysql_select_db('quotes');
if (isset($_POST['quotetext'])) {
$quotetext = $_POST['quotetext'];
$ident = 'yankees';
$sql = "INSERT INTO quote SET
quotetext='$quotetext',
nametext='$name',
ident='$ident',
quotedate=CURDATE()";
header("Location: quotes.php");
if (#mysql_query($sql)) {
} else {
echo '<p> Error adding quote: ' .
mysql_error() . '</p>';
}
}
?>
Your form action stuff looks weird, but regardless, I think the problem you're having has to do with not setting $name = $_POST['name'] like you're doing with $quotetext = $_POST['quotetext']. Do that before the sql statement and it should be good to go.
edit to try to help you further, I'll include what the overall structure of your code should be, and you should tweak it to fit your actual code (whatever you're leaving out, such as setting $query for your name options):
file 1:
<form action="formsubmit.php" method="post">
<label> <br />What did they say?: <br />
<textarea name="quotetext" rows="10" cols="26"></textarea></label>
<select name='name'>
<?php
while ($temp = mysql_fetch_assoc($query)) {
echo "<option>".htmlspecialchars($temp['name'])."</option>";
}
?>
</select>
<input type="submit" value="Submit!" />
</form>
formsubmit.php:
<?php
mysql_select_db('quotes');
if (isset($_POST['quotetext'])) {
$quotetext = $_POST['quotetext'];
$name = $_POST['name'];
$ident = 'yankees';
$sql = "INSERT INTO quote SET
quotetext='$quotetext',
nametext='$name',
ident='$ident',
quotedate=CURDATE()";
if (#mysql_query($sql)) {
header("Location: quotes.php");
} else {
echo '<p> Error adding quote: ' .
mysql_error() . '</p>';
}
}
?>
echo "<select name='name'>";
while ($temp = mysql_fetch_assoc($query)) {
$nyme = htmlspecialchars($temp['name']);
echo "<option value='$nyme'>$nyme</option>";
}
echo "</select>";-
This way you will receive the value of the name in $_POST array
and you have to get that value out of $_POST array as well you need to change the
code add the following line to get the name in your script.
$name = $_POST['name'];
you need to change the form action tag
<form action='formsubmit.php' .....>
and in that file after successful insertion you can redirect the user to whereever.php.
so it was fun explaining you every thing bit by bit change this now in your code as well.
if (#mysql_query($sql)) {
header("Location: quotes.php");
} else {
echo '<p> Error adding quote: ' .
mysql_error() . '</p>';
}