|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
how do you access form elements with PHP?
I'm trying to make a journal of sorts using php and I have been having trouble finding info on how to access form elements.
Here's what I want to do: I have a site that will have one or more journals on it. The dates will be in a listbox and when someone selects a date, the journal entry associated with it shows up in an area beneath (or above) it. This area is a simple div tag with a php variable. does this sound feasable? Is there something more that I need to do to get the entry to show up in the div tag? The errors show up in it already... |
|
#2
|
|||
|
|||
|
RE: how do you access form elements with PHP?
post the code you are currently using so we can get a better idea of exactly what you are doing. Form elements are referenced with the $_POST or $_GET superglobals depending on your form submission method.
|
|
#3
|
|||
|
|||
|
RE: how do you access form elements with PHP?
here's the code that I've been working on if it will help. I've removed all of the unimportant(i think) stuff as well as the greater than/less than signs....
HTML HEAD TITLELfW site5/TITLE link rel=stylesheet href="lfw.css" type="text/css" ?php $xml_file = "journal.xml"; $xml_headline_key = "*JOURNAL*ENTRY*DATE"; $xml_description_key = "*JOURNAL*ENTRY*TEXT"; $story_array = array(); $counter = 0; class xml_story{ var $headline, $description; } function startTag($parser, $data){ global $current_tag; $current_tag .= "*$data"; } function endTag($parser, $data){ global $current_tag; $tag_key = strrpos($current_tag, '*'); $current_tag = substr($current_tag, 0, $tag_key); } function contents($parser, $data){ global $current_tag, $xml_headline_key, $xml_description_key, $counter, $story_array; switch($current_tag){ case $xml_headline_key: $story_array[$counter] = new xml_story(); $story_array[$counter]->headline = $data; break; case $xml_description_key: $story_array[$counter]->description = $data; $counter++; break; } } $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startTag", "endTag"); xml_set_character_data_handler($xml_parser, "contents"); $fp = fopen($xml_file, "r") or die("Could not open file"); $data = fread($fp, filesize($xml_file)) or die("Could not read file"); if(!(xml_parse($xml_parser, $data, feof($fp)))){ die("Error on line " . xml_get_current_line_number($xml_parser)); } xml_parser_free($xml_parser); fclose($fp); ? /HEAD BODY [snip] TD ROWSPAN=2 div style="width:208px;height=245px;z-index:10;"> div ?php echo "<select name="jrhdates">"; for($x=0;$x<count($story_array);$x++){ echo "<option value=".$x .">" . $story_array[$x]->headline . "</option>n"; } echo "</select>"; ?> /div div style="width:204px;height:220px;z-index=10;color:#B4A241;overflow:auto;clip:rect(0px ,200px,210px,0px);" ?php echo $story_array[$_POST['jrhdates']]->description; ? /div /div /BODY /HTML |
|
#4
|
|||
|
|||
|
RE: how do you access form elements with PHP?
things I see are no form tags and no submit button, you can't submit a form if there are no form tags. If you left them out of the script you posted, please repost the script in full, half the script does not help.
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > how do you access form elements with PHP? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|