Jump to content

PHP form code


eaglelegend

Recommended Posts

whats wrong with my PHP/Form code?  ???

 

		print "<h2>Send Message</h2><p>
	<form action='/mail2.php?action=sendmsg' method='post'>
	<input type='radio' name='type' value='1' class='text_box'> Email<br>
	<input type='radio' name='type' value='2' checked class='text_box'> Private Message<br>
	To<br>
	<input type='text' name='to' class='text_box'><p>
	From<br>
	<select name='from' size='1' class='text_box'>";
	<?php
	$sql = mysql_query("SELECT * FROM `members` WHERE `site`=\"$Z\" ORDER BY `username`='".mysql_escape_string($username). ASC");
	while($row = mysql_fetch_array($sql)) {
	 	$us = $row["username"];

	 	print "<option value=\"$us\">$us</option>
	 	<option value=\"[email protected]\">[email protected]</option>";
	}
	?>

	print "</select><p>

Link to comment
https://forums.phpfreaks.com/topic/101078-php-form-code/
Share on other sites

Try this:

 

print "<h2>Send Message</h2><p>
	<form action='/mail2.php?action=sendmsg' method='post'>
	<input type='radio' name='type' value='1' class='text_box'> Email<br>
	<input type='radio' name='type' value='2' checked class='text_box'> Private Message<br>
	To<br>
	<input type='text' name='to' class='text_box'><p>
	From<br>
	<select name='from' size='1' class='text_box'>";
	<?php
	$sql = mysql_query("SELECT * FROM `members` WHERE `site`=\"$Z\" ORDER BY `username`='".mysql_escape_string($username). ASC");
	while($row = mysql_fetch_array($sql)) {
	 	$us = $row["username"];

	 	print "<option value=" . $us . ">" . $us . "</option>
	 	<option value=\"" . $us . "@eaglelegend.com\">" . $us . "@eaglelegend.com</option>";
	}
	?>

	print "</select><p>";

Link to comment
https://forums.phpfreaks.com/topic/101078-php-form-code/#findComment-516878
Share on other sites

Here, I cleaned up your code:

 

<?
echo "<h2>Send Message</h2><p>
	<form action=\"mail2.php?action=sendmsg\" method=\"post\">
	<input type=\"radio\" name=\"type\" value=\"1\" class=\"text_box\"> Email<br />
	<input type='radio' name='type' value='2' checked class='text_box'> Private Message<br />
	To<br />
	<input type=\"text\" name=\"to\" class=\"text_box\"><p>
	From<br />
	<select name=\"from\" size=\"1\" class=\"text_box\">";
	$sql = mysql_query("SELECT * FROM `members` WHERE site = '$Z' ORDER BY `username` = '" . mysql_escape_string($username) . "' ASC");
	while($row = mysql_fetch_array($sql)) {
	 	$us = $row["username"];
	 	print "<option value=\"" . $us . "\">" . $us . "</option>
	 	<option value=\"" . $us . "@eaglelegend.com\">" . $us . "@eaglelegend.com</option>";
	}
	print "</select><p>";
?>

Link to comment
https://forums.phpfreaks.com/topic/101078-php-form-code/#findComment-516884
Share on other sites

thanks unidox, unfortunately, well maybe because it werent all the form im afraid, here is the full form, which includes what you fixed:

 

<?php
echo "<h2>Send Message</h2><p>
	<form action=\"mail2.php?action=sendmsg\" method=\"post\">
	<input type=\"radio\" name=\"type\" value=\"1\" class=\"text_box\"> Email<br />
	<input type='radio' name='type' value='2' checked class='text_box'> Private Message<br />
	To<br />
	<input type=\"text\" name=\"to\" class=\"text_box\"><p>
	From<br />
	<select name=\"from\" size=\"1\" class=\"text_box\">";
	$sql = mysql_query("SELECT * FROM `members` WHERE site = '$Z' ORDER BY `username` = '" . mysql_escape_string($username) . "' ASC");
	while($row = mysql_fetch_array($sql)) {
	 	$us = $row["username"];
	 	print "<option value=\"" . $us . "\">" . $us . "</option>
	 	<option value=\"" . $us . "@eaglelegend.com\">" . $us . "@eaglelegend.com</option>";
	}
	print "</select><p>		
	Subject<br>
	<input type='text' name='subject' size='30' class='text_box'><p>
	Message<br>
	<textarea rows=6 cols=60 nowrap name='message' class='text_box'></textarea><p>
	<input type='submit' value=' Send Message ' class='text_box'></form>";	 
}
?>

Link to comment
https://forums.phpfreaks.com/topic/101078-php-form-code/#findComment-516900
Share on other sites

Here:

 

<?php
echo "<h2>Send Message</h2><p>
	<form action=\"mail2.php?action=sendmsg\" method=\"post\">
	<input type=\"radio\" name=\"type\" value=\"1\" class=\"text_box\"> Email<br />
	<input type=\"radio\" name=\"type\" value=\"2\" checked class=\"text_box\"> Private Message<br />
	To<br />
	<input type=\"text\" name=\"to\" class=\"text_box\"><p>
	From<br />
	<select name=\"from\" size=\"1\" class=\"text_box\">";
	$sql = mysql_query("SELECT * FROM `members` WHERE site = '$Z' ORDER BY `username` = '" . mysql_escape_string($username) . "' ASC");
	while($row = mysql_fetch_array($sql)) {
	 	$us = $row["username"];
	 	print "<option value=\"" . $us . "\">" . $us . "</option>
	 	<option value=\"" . $us . "@eaglelegend.com\">" . $us . "@eaglelegend.com</option>";
	}
	print "</select><p>		
	Subject<br />
	<input type=\"text\" name=\"subject\" size=\"30\" class=\"text_box\"><p>
	Message<br />
	<textarea rows=\"6\" cols=\"60\" nowrap name=\"message\" class=\"text_box\"></textarea><p>
	<input type=\"submit\" value=\" Send Message \" class=\"text_box\"></form>";	 
?>

 

You didnt need the ending }

Link to comment
https://forums.phpfreaks.com/topic/101078-php-form-code/#findComment-516906
Share on other sites

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.