To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > Tools > Dreamweaver

Dreamweaver In need of help with Dreamweaver?

Reply
 
Thread Tools Rate Thread Display Modes
Old 02-07-2003, 08:40 AM   #1
Jim_Madrid
Member
 
Join Date: Feb 2003
Posts: 41
if(empty) statements/session variables

If anyone can help me with this I would be incredibly grateful...have spent days trying to figure this out. Here are the basics

server model: PHP (although if you know it in other server model that okay too...can translate)
database: mysql

1. I have a 2 page form. When the user fills out the info on page form he is directed to the 2nd page of the form. A session variable has been created in the 2nd form to hold all the data from the 1st page. When the 2nd page is submitted all the data (stored from page 1 and new from page 2) are sent to the database.

2. Here is the problem. On page 1, I have several form fields (like combo boxes) that need to work together. For example: I have a text field (name=phylum) in which investigators add new phylum names which are eventually sent to database field "phylum" of the same name. Next to that is a select box (name=newphylum) that has all the names that the investigors have previously entered and that are dynamically retrieved from the database field "phylum".

So when a researcher fills out page 1 of the form he/she can either add a new name or select an already existing name from the select box. But just one of these values can be sent to the database, not both.

QUESTION 1:

How can I say and where would I put something that basically says the following:

if the phylum text field is left EMPTY (i.e. they donīt add a new name) and they select instead from the select box, that it is the value from the select box and not the text box that gets sent to the database.

QUESTION 2:

How do I pass the statement from question 1 into the session variable on page 2 of my form?


Iīm at my wits end with this....Please help if you can

Thanks

Jim
Madrid, Spain
Jim_Madrid is offline   Reply With Quote
Old 02-15-2003, 01:24 AM   #2
KevinMG
Member
 
Join Date: Aug 2002
Posts: 71
as far as testing if it's an empty entry, try the following

PHP Code:
if(empty($newphylum)) {
//do something with new phylum
} else {
//do something with selected phylum
}
as far as passing information between the two forms, i wouldn't personally use sessions. i'd take advantage of the $_POST (avail in PHP4.1.x or higher) variables. you can traverse all the different variables posted to your script using something like the following

PHP Code:
while(list($key,$val) = each($array)) {
echo
"$key -> $val";
}
so you could take that general idea and turn all the passed variables into hidden variables of form 2, which would all then re-post themselves to your 3rd (and final?) page....so something like this...

PHP Code:
$hiddenList = "";
while(list(
$key,$val) = each($_POST)) {
$hiddenList .= "<input type=\"hidden\" name=\"$key\" value=\"$val\">";
}
do note you can run into troubles with this method when quotes are entered

hope that helped a bit...good luck
__________________
EndsDesign.com
KevinMG is offline   Reply With Quote
Old 03-05-2003, 11:09 AM   #3
CJ@G3
Junior Member
 
Join Date: Mar 2003
Location: Hertfordshire, UK
Posts: 11
why not have both html and php in one file, and detect whether the form is subbmitted by something like:
PHP Code:
if($input1)
{
#process form contents to database etc.#
}
else
{
#print html form page#
}
$input1 being an input field on the form that is mandatory.

Hope this helps a little.


CJ
CJ@G3 is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 06:06 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.