bam2550 Posted May 10, 2008 Share Posted May 10, 2008 Okay well, i have a private messaging system. I am trying to fix up the send form... But im hitting some brick walls... What my work looks like as of now! Question: 1) How do i set a value to a drop down menu so it sends the selected information (POST) to send.php 2) How do i make it so Subject is not invisible, and on the line below the drop down menu. Thanks thats it! Here is what you might need: form.html <html> <select> <?php $con = mysql_connect("localhost","3434","45345"); mysql_select_db("login", $con); $result = mysql_query("SELECT * FROM users", $con); while($row = mysql_fetch_array($result)) { ?> Send to: <option><?php echo $row['username']; ?></option> <?php } ?> <form action="send.php" method="POST"> <br> Subject: <br><input type="text" name="sub"> <br> Your Message: <br><textarea name="msg" rows="10" cols="45"></textarea><br> <input type="submit" value="Send"> </form> <?php echo "<br>Back To [<a href=\"main.php\">Main</a>]<br><br/>"; ?> </select> </html> This is what i want the drop down menu to be set to... $sendto = trim(mysql_real_escape_string($_POST["to"])); Link to comment https://forums.phpfreaks.com/topic/105044-drop-down-menu-mysql-php/ Share on other sites More sharing options...
Fadion Posted May 10, 2008 Share Posted May 10, 2008 <select><option></option></select> must be all inside the form. Use value="someValue" in the <option> tag to assign a value to that option. Use name="to" to assign a name to the <select> so u can call it with post. Your code should look: <html> <form action="send.php" method="POST"> <select name="to"> <?php $con = mysql_connect("localhost","3434","45345"); mysql_select_db("login", $con); $result = mysql_query("SELECT * FROM users", $con); while($row = mysql_fetch_array($result)) { ?> Send to: <option value="<?php echo $row['username']; ?>"><?php echo $row['username']; ?></option> <?php } ?> </select> <br> Subject: <br><input type="text" name="sub"> <br> Your Message: <br><textarea name="msg" rows="10" cols="45"></textarea><br> <input type="submit" value="Send"> </form> <?php echo "<br>Back To [<a href=\"main.php\">Main</a>]<br><br/>"; ?> </html> Link to comment https://forums.phpfreaks.com/topic/105044-drop-down-menu-mysql-php/#findComment-537714 Share on other sites More sharing options...
bam2550 Posted May 10, 2008 Author Share Posted May 10, 2008 Okay, one small problem and one small thing to say! The one small thing is i didnt want a value, i just got my words mixed up The one small problem is that in my text editor (linux ubuntu, which usually always colors PHP syntax) is not coloring in my PHP stuff, only HTML... I think this is affecting the code since the script does not work now... This is my form... <html> <form action="send.php" method="POST"> <select name="to"> <?php $con = mysql_connect("localhost","3434","45345"); mysql_select_db("login", $con); $result = mysql_query("SELECT * FROM users", $con); while($row = mysql_fetch_array($result)) { ?> Send to: <option> <?php echo $row['username']; ?> </option> <?php } ?> </select> <br> Subject: <br><input type="text" name="sub"> <br> Your Message: <br><textarea name="msg" rows="10" cols="45"></textarea><br> <input type="submit" value="Send"> </form> <?php echo "<br>Back To [<a href=\"main.php\">Main</a>]<br><br/>"; ?> </html> Link to comment https://forums.phpfreaks.com/topic/105044-drop-down-menu-mysql-php/#findComment-537737 Share on other sites More sharing options...
bam2550 Posted May 10, 2008 Author Share Posted May 10, 2008 Thanks, i fixed it! Link to comment https://forums.phpfreaks.com/topic/105044-drop-down-menu-mysql-php/#findComment-537746 Share on other sites More sharing options...
Fadion Posted May 10, 2008 Share Posted May 10, 2008 Glad u worked it out. Mark the topic as solved if u dont have any other issues. Link to comment https://forums.phpfreaks.com/topic/105044-drop-down-menu-mysql-php/#findComment-537878 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.