eaglelegend Posted April 14, 2008 Share Posted April 14, 2008 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 More sharing options...
unidox Posted April 14, 2008 Share Posted April 14, 2008 Whats the error? Link to comment https://forums.phpfreaks.com/topic/101078-php-form-code/#findComment-516873 Share on other sites More sharing options...
eaglelegend Posted April 14, 2008 Author Share Posted April 14, 2008 parse: Parse error: syntax error, unexpected '<' in /misc/39/000/171/334/2/user/web/eaglelegend.com/mail2.php on line 80 line 80 is the start of <?php Link to comment https://forums.phpfreaks.com/topic/101078-php-form-code/#findComment-516875 Share on other sites More sharing options...
unidox Posted April 14, 2008 Share Posted April 14, 2008 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 More sharing options...
trq Posted April 14, 2008 Share Posted April 14, 2008 You have a parse error in your query, not to mention the fact that is is invalid sql. Link to comment https://forums.phpfreaks.com/topic/101078-php-form-code/#findComment-516880 Share on other sites More sharing options...
unidox Posted April 14, 2008 Share Posted April 14, 2008 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 More sharing options...
eaglelegend Posted April 14, 2008 Author Share Posted April 14, 2008 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 More sharing options...
unidox Posted April 14, 2008 Share Posted April 14, 2008 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 More sharing options...
eaglelegend Posted April 14, 2008 Author Share Posted April 14, 2008 Ok, thank you I did that but still Parse error: syntax error, unexpected '<' in /misc/39/000/171/334/2/user/web/eaglelegend.com/mail2.php on line 72 line 72 is the start of <?php Link to comment https://forums.phpfreaks.com/topic/101078-php-form-code/#findComment-516915 Share on other sites More sharing options...
unidox Posted April 14, 2008 Share Posted April 14, 2008 I need to see the full code, of both pages. Link to comment https://forums.phpfreaks.com/topic/101078-php-form-code/#findComment-516953 Share on other sites More sharing options...
eaglelegend Posted April 14, 2008 Author Share Posted April 14, 2008 its actually 1 page, I just put "2" as it the original one is their and I don't want to chance having a not complete mail system publicly available for people to abuse you know? thanks! Link to comment https://forums.phpfreaks.com/topic/101078-php-form-code/#findComment-516957 Share on other sites More sharing options...
unidox Posted April 14, 2008 Share Posted April 14, 2008 How would people abuse it? Just use ** to block out any emails you dont want public. The code I gave you comes with no errors, I need to see it all otherwise I cant help. Link to comment https://forums.phpfreaks.com/topic/101078-php-form-code/#findComment-516959 Share on other sites More sharing options...
eaglelegend Posted April 14, 2008 Author Share Posted April 14, 2008 I mean it is a PM & Email thing, it could be abused as the "from" you could change.. Link to comment https://forums.phpfreaks.com/topic/101078-php-form-code/#findComment-516962 Share on other sites More sharing options...
unidox Posted April 14, 2008 Share Posted April 14, 2008 Well PM me it you would like. I am trying to help, but you have to come 50% also. Link to comment https://forums.phpfreaks.com/topic/101078-php-form-code/#findComment-516964 Share on other sites More sharing options...
trq Posted April 14, 2008 Share Posted April 14, 2008 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 https://forums.phpfreaks.com/topic/101078-php-form-code/#findComment-516965 Share on other sites More sharing options...
eaglelegend Posted April 14, 2008 Author Share Posted April 14, 2008 ok, how comes is sql have a problem? Link to comment https://forums.phpfreaks.com/topic/101078-php-form-code/#findComment-516969 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.