Solved

else statement help needed

Posted on 2009-05-05
3
243 Views
Last Modified: 2012-05-06
hello. i am confused as to why this statement is not including the file 'formvars.php' and always going to 'transform.php' no matter what way round i put it. Var_dump shows me that the string is being passed "Vehicle Transport" which is correct but if another string say "hello" is passed it should go to 'formvars.php'. any help gratefully received. many thanks
<?php  

if (empty($prez)) { echo $error_job; } 

elseif (isset($_POST['Intext'])=="Vehicle Transport") 

{ echo $stage2_msg; include 'transform.php'; } 

else {  echo $stage2_msg; include 'formvars.php'; }

 ?>

Open in new window

0
Comment
Question by:peter_coop
3 Comments
 
LVL 8

Accepted Solution

by:
mostart earned 500 total points
ID: 24304210
try like this:


<?php  

if (empty($prez)) { echo $error_job; } 

elseif (isset($_POST['Intext']) && $_POST['Intext'] =="Vehicle Transport") 

{ echo $stage2_msg; include 'transform.php'; } 

else {  echo $stage2_msg; include 'formvars.php'; }

?>

Open in new window

0
 
LVL 4

Expert Comment

by:bljak
ID: 24304232
Because your "elseif" statement ist wrong.
It should be rather something like piece of code below.
<?php  

if ( empty($prez) )

{

	echo $error_job;

}

elseif ( isset($_POST['Intext']) && $_POST['Intext'] == "Vehicle Transport" )

{

	echo $stage2_msg;

	include "transform.php";

} 

else

{

	echo $stage2_msg;

	include "formvars.php";

}

?>

Open in new window

0
 

Author Closing Comment

by:peter_coop
ID: 31577999
excellent. couldn't see for looking :-) thanks very much
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
php email 2 26
How to use md5 hashing 3 25
How can I echo a PHP variable in AJAX function? 7 27
Scope of $_SESSION 17 25
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now