anp24 Posted June 22, 2011 Share Posted June 22, 2011 Hello, I have a PHP page with a list of records coming from the database through the while loop. Each record can be edited with the edit link with code as <form action='' method='post' name='fr'> <input type='image' src='images/edit.png' name='task' value='Edit' /> </form> Now I want to know, if I want to pass Edit Id for each record through session variable, How can I do this. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 22, 2011 Share Posted June 22, 2011 just add a hidden element with the id: <form action='' method='post' name='fr'> <input type='image' src='images/edit.png' name='task' value='Edit' /> <input type='hidden' name='ElemID' value='123' /> </form> Quote Link to comment Share on other sites More sharing options...
anp24 Posted June 22, 2011 Author Share Posted June 22, 2011 Hello, I do not want the hidden element. I only want the value to pass through session variable. Thanks Regards Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 22, 2011 Share Posted June 22, 2011 yeah, I got that, but to pass it through the session, first you need to know what it is, then you need to place it in the session. so you use the hidden field so you can grab it and place it in the session, otherwise how do you know which one was selected by the user? Quote Link to comment Share on other sites More sharing options...
anp24 Posted June 22, 2011 Author Share Posted June 22, 2011 Hello, Can the value come in PHP Server Side variable instead of hidden field, then that value will be sent through the session variable. Thanks Regards Quote Link to comment Share on other sites More sharing options...
TeNDoLLA Posted June 22, 2011 Share Posted June 22, 2011 Do you mean ? <input type='hidden' name='ElemID' value='<?php echo $yourValue; ?>' /> Quote Link to comment Share on other sites More sharing options...
anp24 Posted June 22, 2011 Author Share Posted June 22, 2011 Hello, Only in Server Side PHP Code and no hidden field. This means that ID value is stored in an array and when user selects that particular record, the value from array will be passed to the session variable. Thank You Regards Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 22, 2011 Share Posted June 22, 2011 still, the problem will be the same. how do you know which record was selected by the user if you do not POST some sort of identifier? Quote Link to comment Share on other sites More sharing options...
TeNDoLLA Posted June 22, 2011 Share Posted June 22, 2011 You should try to understand what WebStyles is saying for the second time now. Or you should try to be more specific with your explanation what you want, maybe show some more code or something. I am so confused really. Quote Link to comment Share on other sites More sharing options...
EmperorJazzy Posted June 22, 2011 Share Posted June 22, 2011 I've done a similar thing with editing of records and as WebStyles says; use a hidden element. Quote Link to comment Share on other sites More sharing options...
anp24 Posted June 22, 2011 Author Share Posted June 22, 2011 But the hidden element can be tampered with by intercepting Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 22, 2011 Share Posted June 22, 2011 use a hidden element with a different set of id's that will allow you to index the real id in your session array. Quote Link to comment Share on other sites More sharing options...
TeNDoLLA Posted June 22, 2011 Share Posted June 22, 2011 Or just check the validity of the values that comes from from and then proceed or show error message. This is what you should do in any case. Always validate user input. 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.