contra10 Posted January 2, 2009 Share Posted January 2, 2009 maybe im attempting this the wrong way but i want to put a form in the brackets as im attempting to have an add friend, reject friend. If i put the form seperate then it will only say add friend and reject friend once instead for each person who adds the user my code is <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); $requestint = 1; $data = ("SELECT * FROM friend_request WHERE requestname = '$username' AND value = '$requestint' ORDER BY frid DESC") or die(mysql_error()); $postrequest = mysql_query($data); while($info = mysql_fetch_array($postrequest)) { $userrequesting= "{$info['username']}"; echo "$userrequesting wants to be your friend <input type='submit' name='add' value='Add Friend'> <input type='submit' name='reject' value='Reject Friend'></a><br>"; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0" width="500" align="center" height="100"> <tr> <td align="right"><input type="submit" name="add" value="Add Friend"></td> <td align="right"><input type="submit" name="reject" value="Reject Friend"></td></tr> </table> </form> the form in the php brackets or the buttons of the form are the way that i want my request to look like, but i need to do an action and i can't put $_SERVER['PHP_SELF']; tell me if im making any sense Link to comment https://forums.phpfreaks.com/topic/139223-solved-putting-a-form-in-php-brackets/ Share on other sites More sharing options...
GingerRobot Posted January 2, 2009 Share Posted January 2, 2009 1.) You need to place that loop between the <form> tags - otherwise those submit buttons you're echoing wont be part of the form. 2.) You're going to need some way of identifying which friend requests are being accepted/rejected. Perhaps make the submit button's name an array with the id of the friend/friend request as the key. Link to comment https://forums.phpfreaks.com/topic/139223-solved-putting-a-form-in-php-brackets/#findComment-728222 Share on other sites More sharing options...
contra10 Posted January 2, 2009 Author Share Posted January 2, 2009 something like this <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0" width="500" align="center" height="100"> <tr> <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); $requestint = 1; $data = ("SELECT * FROM friend_request WHERE requestname = '$username' AND value = '$requestint' ORDER BY frid DESC") or die(mysql_error()); $postrequest = mysql_query($data); while($info = mysql_fetch_array($postrequest)) { $userrequesting= "{$info['username']}"; echo "$userrequesting wants to be your friend <input type='submit' name='add' value='Add Friend'> <input type='submit' name='reject' value='Reject Friend'></a><br>"; } ?> </table> </form> ? Link to comment https://forums.phpfreaks.com/topic/139223-solved-putting-a-form-in-php-brackets/#findComment-728226 Share on other sites More sharing options...
contra10 Posted January 2, 2009 Author Share Posted January 2, 2009 where exaclty should i set up the array? and what should i input? Link to comment https://forums.phpfreaks.com/topic/139223-solved-putting-a-form-in-php-brackets/#findComment-728229 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.