Jump to content

How to store dropbox data


xxreenaxx1

Recommended Posts

Hey

 

I created a drop box and got a form for that. Now when I click on submit I want the data to be compaired with the data inside the mysql.

 

For example: Subject name = Subject id

 

the drop down list contains subject names. And this should be compaired with the subject id and store the id into a new table called test.

 

<Html>

<?php
session_start();
include '../Database/connection.php';



?>

<body>
<form action="try1.php" method="post">
<?PHP


include '../Database/subject_sql.php';


$result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() );
echo "<select name=myselect>";

while($row=mysql_fetch_array($result)){

echo "<OPTION VALUE=".$row['Sub_ID'].">".$row['Sub_Name']."</OPTION>";
}

echo "</select>";

?>

<input type="submit" value="submit"/>
</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/227880-how-to-store-dropbox-data/
Share on other sites

I dont want you to write the program. I just want help... direct me to correct tutorial or what ever.. And I will do it.. I dont know how to post that dropbox and use the subject which is being chosen to be compared with Subject ID and insert that into a different table.

  Quote

I dont want you to write the program. I just want help... direct me to correct tutorial or what ever.. And I will do it.. I dont know how to post that dropbox and use the subject which is being chosen to be compared with Subject ID and insert that into a different table.

 

Again, still not sure what you are looking for. Do you not know how to process form data? Have you not done a database INSERT or what?

 

Here is an example:

//Get & clean value from POST data
$postedValue = mysql_real_escape_string(trim($_POST['myselect']));

//Create and run INSERT query
$query = "INSERT INTO test (`Sub_ID`) VALUES ({$postedValue})";
$result = mysql_query($query) or die (mysql_error());

Yeh sort of. I need to insert Use_ID from a session as well. and then enter other details from a new form. But I want to be able to add all these to one table.

 

<table border="0">
<form method="POST" action="try2.php">
<tr><td>Tes_Name</td><td>:</td><td><input type="text" name="Tes_Name" size="20"></td></tr>
<tr><td>Tes_Description</td><td>:</td><td><input type="text" name="Tes_Description" size="20"></td></tr>
<tr><td> </td><td> </td><td><input type="submit" value="Submit"></td></tr>
</form>
</table>

OK, so you would parse the other variables from the POST data and the SESSION value as I did with $_POST['myselect'] and add them to the query.

 

//Get & clean values from POST/SESSION data
$postVar1 = mysql_real_escape_string(trim($_POST['inputField1']));
$postVar2 = mysql_real_escape_string(trim($_POST['inputField2']));
$postVar3 = mysql_real_escape_string(trim($_POST['inputField3']));
$postVar4 = mysql_real_escape_string(trim($_POST['inputField4']));
$SessionVar1 = mysql_real_escape_string(trim($_SESSION['sessionVar1']));

//Create and run INSERT query
$query = "INSERT INTO test (`dbField1`, `dbField2`, `dbField3`, `dbField4`, `dbField5`)
          VALUES ('{$postVar1}', '{$postVar2}', '{$postVar3}', '{$postVar4}', '{$SessionVar1}')";
$result = mysql_query($query) or die (mysql_error());

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.