xxreenaxx1 Posted February 16, 2011 Share Posted February 16, 2011 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> Quote Link to comment https://forums.phpfreaks.com/topic/227880-how-to-store-dropbox-data/ Share on other sites More sharing options...
Psycho Posted February 16, 2011 Share Posted February 16, 2011 So, what exactly are you having a problem with? Are you wanting someone to just write the code for you? If so, this is the wrong forum. Quote Link to comment https://forums.phpfreaks.com/topic/227880-how-to-store-dropbox-data/#findComment-1175059 Share on other sites More sharing options...
xxreenaxx1 Posted February 16, 2011 Author Share Posted February 16, 2011 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 Link to comment https://forums.phpfreaks.com/topic/227880-how-to-store-dropbox-data/#findComment-1175066 Share on other sites More sharing options...
Psycho Posted February 16, 2011 Share Posted February 16, 2011 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()); Quote Link to comment https://forums.phpfreaks.com/topic/227880-how-to-store-dropbox-data/#findComment-1175076 Share on other sites More sharing options...
xxreenaxx1 Posted February 16, 2011 Author Share Posted February 16, 2011 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> Quote Link to comment https://forums.phpfreaks.com/topic/227880-how-to-store-dropbox-data/#findComment-1175093 Share on other sites More sharing options...
Psycho Posted February 16, 2011 Share Posted February 16, 2011 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()); Quote Link to comment https://forums.phpfreaks.com/topic/227880-how-to-store-dropbox-data/#findComment-1175113 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.