Jump to content

Button post problem...


IER506

Recommended Posts

Good morning everyone. I don't actually know if this is the right place for this question.

I have a php page with multiple drop down menus which generate a query sent to a db.

Everything works with $_POST. I am now trying to add a delete button next to every record.

 

The problem is that i have to name the buttons in a specific way. I give them the name DBID

and once one is pressed in posts its name to the same page and a deletion query is performed.

 

I do not want the name to be the DBID and I was wondering about the following two:

 

1.Can I have a different name?

2.What other techniques do you suggest for the deletion. Please note that the page has multiple

drop down lists with "memory". This is performed via $_POST check each time a refresh is performed.

 

 

Thanks in advance for your help!

Link to comment
https://forums.phpfreaks.com/topic/208871-button-post-problem/
Share on other sites

The code I'm using is actually pretty simple:

 


if($_POST['hiddendbid'])
{

$setreadquery = "UPDATE MAIN SET messages.READ = 'YEP', messages.READBY='".$_SESSION['username']."' WHERE DBID = ".$_POST['hiddendbid'];

$connecttoedit = mysql_connect("localhost","root","") or die ("Could not connect to msw database");

mysql_select_db("messages") or die ("Could not find database");

$setmsgisread = mysql_query($setreadquery);

}

unset($_POST['hiddendbid']);


 

And inside a while loop which retrieves the data from my sql db i generate a button (if a message is not readed):

 

 


if ($dbrea=="NOP"){

$readbutton = '<br><input type="submit" name="hiddendbid" value="'.$dbid.'" onclick="this.form.submit();"> <-Delete';
}

elseif ($dbrea!=="NOP"){

$readbutton = '';

}

Link to comment
https://forums.phpfreaks.com/topic/208871-button-post-problem/#findComment-1091457
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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