Jump to content

Recommended Posts

[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;t

anyone help me out please?
Link to comment
https://forums.phpfreaks.com/topic/35439-form-field-not-working/
Share on other sites

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 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 tho

all the code is within myprivatemessages.php

it doesnt even echo the 'weeeeee'
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 anything

if (isset($_POST['Submit'])) {
echo "the delete was clicked!";
}
At the start of the script "myprivatemessages.php" put in these lines:
[code]<?php
echo '<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 author=kenrbnsn link=topic=123735.msg511881#msg511881 date=1169595688]
At the start of the script "myprivatemessages.php" put in these lines:
[code]<?php
echo '<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
)

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 :-P

You might want to check the other value, instead of submit, or set another hidden or something, because of the image problem.
ahh i see now :D

this 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 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]
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.