Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #3615
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: test if $_POST variable is set |
| Date | 2011-10-29 09:38 +0100 |
| Organization | albasani.net |
| Message-ID | <j8ge1d$mtf$1@news.albasani.net> (permalink) |
| References | <71818aa4-0d6f-46e1-aec4-ab37302e6bfa@u13g2000prm.googlegroups.com> |
cerr wrote:
> Hi There,
>
> I have a form with various checkboxes, they got names i have from a db
> to identify them.
> Now I would like to check what has been posted by the form. For that I
> would like to read all the field names from the db and check if they
> have been set something like this:
>
> $result = mysql_query("SELECT * FROM specialty");
> while($row = mysql_fetch_array($result)) {
> if (isset($_POST[$row['name']])) {
> var_dump($POST);
> session_unset();
> }
>
> But this doesn't seem to work the way I expected it to? I.e. I would
> liek to check if $_POST['MyCheckbox'] is set now but MyCheckbox is a
> name from the database. How do I do this best, the easiest way?
>
> Thanks,
> Ron
To extract column names from the database is non trivial.
I woudl suggets another approach.
Like set up an array of mysql field names and use that to both do the
select of the data, and to scan through to see if it exists
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
test if $_POST variable is set cerr <ron.eggler@gmail.com> - 2011-10-28 22:40 -0700
Re: test if $_POST variable is set The Natural Philosopher <tnp@invalid.invalid> - 2011-10-29 09:38 +0100
Re: test if $_POST variable is set Richard Damon <news.x.richarddamon@xoxy.net> - 2011-10-29 09:04 -0400
Re: test if $_POST variable is set Denis McMahon <denismfmcmahon@gmail.com> - 2011-10-29 13:16 +0000
Re: test if $_POST variable is set Denis McMahon <denismfmcmahon@gmail.com> - 2011-10-29 13:09 +0000
Re: test if $_POST variable is set Jerry Stuckle <jstucklex@attglobal.net> - 2011-10-29 09:26 -0400
Re: test if $_POST variable is set cerr <ron.eggler@gmail.com> - 2011-10-29 11:39 -0700
csiph-web