PHP if isset issue

I have a php page that has two forms on it.  The first form when submitted, you stay on the same page.   The first form has a place for you to enter an email address and pick a state from a select.  The second form also has a spot for your email address and also a place to choose a state from a select.  I want to populate email input and the state select with email that was entered earlier and the state that was selected.
First Form:
<select name="bike_state" id="bike_state" {sticky}>
			<div><option value="" style="display:none">Choose State</option></div>
			<?php
				$query = ee()->db->query('SELECT id, state FROM exp_state_rates');
				foreach ($query->result() AS $row)
				{
					echo '<option name="bike_state" class="option-center" value="'.$row->id.'" >'.$row->state.'</option>';	
				}
			?>
		</select>
<input type="text" name="email_value" id="email_value" value="<?php if(isset($_POST['email_value'])) {echo $_POST['email_value'];} else {echo 'Email Address';} ?>" onfocus="this.value='';" />

Open in new window

Second Form:
<select name="item_options[location_state]" id="bike_state" {sticky}>
						<option disabled >Choose State</option>
						<?php
							$query = ee()->db->query('SELECT state FROM exp_state_rates');
							foreach ($query->result() AS $row)
							{
								echo '<option name="bike_state" class="option-center" value="'.$row->state.'" >'.$row->state.'</option>';	
							}
						?>
					</select>		
<input type="text" name="item_options[contact_email]" value="" />	

Open in new window

Any ideas on how I need to write the "if(isset($_POST" statement?  Thanks for your help.  My initial ideas did not work and I feel like I am spinning my wheels.
LVL 8
rgranlundAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
This is what I use.
if (!isset($_POST['fname'])) {$fname = "";} else {$fname = $_POST['fname'];}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgranlundAuthor Commented:
What about the <select> <option> ???
0
Dave BaldwinFixer of ProblemsCommented:
What about it?  Use the result from the 'if' statement in the Select statement.  Separate lines.  Every PHP page that I post to has the 'if(!isset...' statements for all of the incoming variables at the top of the page.  I would never put all that PHP in the middle of that.  If you look at the PHP Email demo I have posted many times you will see that at the top of that file.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.