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=\"$us@eaglelegend.com\">$us@eaglelegend.com</option>";
	}
	?>

	print "</select><p>

Link to comment
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
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
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
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
Share on other sites

The error your getting would be caused by already being in php then using the <?php tags again. If your already witjhin php you don't need nested <?php ?> tags.

 

Once you fix that though, your query is invalid also.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.