pouncer Posted January 23, 2007 Share Posted January 23, 2007 [code]<form method ='post' action='myprivatemessages.php' name='record'> <td><input name='Submit' type=\"image\" src=\"../index_images/delete.ico\" ></td> <input type='hidden' name='message_id' value='$message_id'></form>[/code]and then below i have:[code] if (isset($_POST['Submit'])) { $message_id = $_GET['message_id']; echo "weeeeee" . $message_id; }[/code]but when i click on the delete icon, it should echo that, but it doesn;tanyone help me out please? Quote Link to comment Share on other sites More sharing options...
trq Posted January 23, 2007 Share Posted January 23, 2007 No need to escape quotes unless your within php.[code]<td><input name='Submit' type='image' src='../index_images/delete.ico' ></td>[/code] Quote Link to comment Share on other sites More sharing options...
pouncer Posted January 23, 2007 Author Share Posted January 23, 2007 Sorry, i should have pasted more. it is within PHP, it just adds the records to a table with a delete.ico next to each record incase i want to delete the entry[code] <?php $Me = $_SESSION['Username']; $Get_Messages = mysql_query("SELECT count(message_id) FROM private_messages WHERE To_='$Me'"); if (mysql_num_rows($Get_Messages) < 1) echo "You have no private messages.<br>"; else { $Num_Messages = mysql_result($Get_Messages, 0, 'count(message_id)'); echo "You have a total of " . $Num_Messages . " private message(s)<br><br>"; echo "<img src='../index_images/read.gif'>" . " read message " . "<img src='../index_images/unread.gif'>" . " unread message " . "<img src='../index_images/delete.ico'>" . " delete message"; $priv = mysql_query("SELECT * FROM private_messages WHERE To_='$Me'"); echo " <table width=90% cellpadding=0 cellspacing=3 border=0 align=center> <tr> <th></th> <th bgcolor=#E1E4F2>Message</th> <th bgcolor=#E1E4F2>Date sent</th> <th></th> </tr>"; while ($message_info = mysql_fetch_array($priv)) { $message_id = $message_info['message_id']; $message_from = stripslashes($message_info['From_']); $message_subject = stripslashes($message_info['Subject']); $message_datesent = stripslashes($message_info['Date_Sent']); $message_read = stripslashes($message_info['Recipient_Read']); if ($message_read == 1) $image = "../index_images/read.gif"; else $image = "../index_images/unread.gif"; echo " <tr> <td><img src=\"$image\"></td> <td align=left bgcolor=#F5F5FF><a href=\"hghg\">Re: $message_subject</a><br>$message_from</td> <td align=center bgcolor=#F5F5FF>$message_datesent</td> <form method ='post' action='myprivatemessages.php' name='record'> <td><input name='Submit' type=\"image\" src=\"../index_images/delete.ico\" ></td> <input type='hidden' name='message_id' value='$message_id'> </form> </tr>"; } echo "</table>"; } ?> <?php if (isset($_POST['Submit'])) { $message_id = $_GET['message_id']; echo "weeeeee" . $message_id; } ?>[/code]it just doesnt want to echo when i click the delete icon Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted January 23, 2007 Share Posted January 23, 2007 You're using the POST method, so you should be looking in the $_POST array for the message_id:[code]<?php$message_id = $_POST['message_id'];?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
pouncer Posted January 23, 2007 Author Share Posted January 23, 2007 [quote author=kenrbnsn link=topic=123735.msg511855#msg511855 date=1169594803]You're using the POST method, so you should be looking in the $_POST array for the message_id:[code]<?php$message_id = $_POST['message_id'];?>[/code]Ken[/quote]thanks, didnt work thoall the code is within myprivatemessages.phpit doesnt even echo the 'weeeeee' Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted January 23, 2007 Share Posted January 23, 2007 yours looks like[code]<form ='something.php'[/code]it should be[code]<form=\"something.php\"[/code]no whitespace. escape doublequotes. Quote Link to comment Share on other sites More sharing options...
pouncer Posted January 23, 2007 Author Share Posted January 23, 2007 just tried that..[code]<form method ='post' action=\"myprivatemessages.php\" name='record'> <td><input name='Submit' type=\"image\" src=\"../index_images/delete.ico\" ></td> <input type='hidden' name='message_id' value='$message_id'></form>[/code]but still, when i click the delete icon, it doesnt even echo anythingif (isset($_POST['Submit'])) { echo "the delete was clicked!";} Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 23, 2007 Share Posted January 23, 2007 pouncer, Submit is empty, it has no value. Perhaps add [code]<input name='Submit' type=\"image\" src=\"../index_images/delete.ico\" value="Submit">[/code] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted January 23, 2007 Share Posted January 23, 2007 At the start of the script "myprivatemessages.php" put in these lines:[code]<?phpecho '<pre>$_GET: ' . print_r($_GET,true) . '</pre>';echo '<pre>$_POST: ' . print_r($_POST,true) . '</pre>';?>[/code]This will dump the values being passed to your script from the form.Ken Quote Link to comment Share on other sites More sharing options...
pouncer Posted January 23, 2007 Author Share Posted January 23, 2007 [quote author=jesirose link=topic=123735.msg511877#msg511877 date=1169595625]pouncer, Submit is empty, it has no value. Perhaps add [code]<input name='Submit' type=\"image\" src=\"../index_images/delete.ico\" value="Submit">[/code][/quote]still no luck :'( Quote Link to comment Share on other sites More sharing options...
pouncer Posted January 23, 2007 Author Share Posted January 23, 2007 [quote author=kenrbnsn link=topic=123735.msg511881#msg511881 date=1169595688]At the start of the script "myprivatemessages.php" put in these lines:[code]<?phpecho '<pre>$_GET: ' . print_r($_GET,true) . '</pre>';echo '<pre>$_POST: ' . print_r($_POST,true) . '</pre>';?>[/code]This will dump the values being passed to your script from the form.Ken[/quote]i gt this:$_GET: Array()$_POST: Array( [message_id] => 14 [Submit_x] => 10 [Submit_y] => 4) Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted January 23, 2007 Share Posted January 23, 2007 What browser are you using? When using an image as a submit button, MSIE passes the X & Y locations within the image back to the script, not the plain name.Ken Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 23, 2007 Share Posted January 23, 2007 Ah, because it's an image, you can't just check Submit, you have to check the Submit_x and y. Try that.Ken, jinx :-PYou might want to check the other value, instead of submit, or set another hidden or something, because of the image problem. Quote Link to comment Share on other sites More sharing options...
pouncer Posted January 23, 2007 Author Share Posted January 23, 2007 ahh i see now :Dthis worked![code] if (isset($_POST['Submit_x']) && isset($_POST['Submit_y'])) { $message_id = $_POST['message_id']; echo "the delete was clicked on messageid: " . $message_id; }[/code]:D Thanks guys, and if there is perhaps a better way, please tell me:p Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted January 23, 2007 Share Posted January 23, 2007 You only have to check submit_x or submit_y, since if one is set the other will be also.Ken Quote Link to comment Share on other sites More sharing options...
pouncer Posted January 23, 2007 Author Share Posted January 23, 2007 [quote author=kenrbnsn link=topic=123735.msg511901#msg511901 date=1169596268]You only have to check submit_x or submit_y, since if one is set the other will be also.Ken[/quote]Thanks.[code=php:0]if (isset($_POST['Submit_x'])) { $message_id = $_POST['message_id']; echo "the delete was clicked on messageid: " . $message_id;}[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.