Page 1 of 1
If value == then open page ?
Posted: Wed Jul 21, 2004 8:51 pm
by zeroanarchy
Hi i am a little stuck on the following code, what I am trying to do is if the vale of the two drop down boxes is == then open a specific page in the following window.
Any ideas? thanks for your time on this.
zeroanarchy
Code: Select all
<?PHP
Function test()
if ($country != "Australia") && ($to == "Bob")
form action ="listing91.php"
elseif ($country != "Australia") && ($to == "Jim")
form action ="listing92.php"
elseif ($country == "Australia") && ($to == "Peter")
form action ="listing93.php"
else
Print "Sorry someone has made an error";
?>
I am using the
Code: Select all
<form action ="test">
// Two drop down fields in here
<input type="submit" value="Build Letter">
<input type="reset" value="Reset form">
feyd | flipped a
Posted: Wed Jul 21, 2004 9:23 pm
by PrObLeM
um braces would be cool also do $action = "whaterver";
then on the <form action="$action">
basically
Posted: Wed Jul 21, 2004 9:51 pm
by ol4pr0
Untested !
Why not something like this.
Code: Select all
<?PHP
<form action ="<?$_SERVER['PHP_SELF']?>">
// Two drop down fields in here
<input type="submit" value="Build Letter">
<input type="reset" value="Reset form">
#assuming you have to drop down fields with name="country" and name="to"
if (isset($_POST['submit']))
{
test ($_POST['country'],$_POST['to']);
function test($country,$to)
if ($country != "Australia") && ($to == "Bob")
form action ="listing91.php"
elseif ($country != "Australia") && ($to == "Jim")
form action ="listing92.php"
elseif ($country == "Australia") && ($to == "Peter")
form action ="listing93.php"
else
Print "Sorry someone has made an error";
}
?>
Posted: Wed Jul 21, 2004 11:04 pm
by feyd
zeroanarchy, I'm not quite sure what you're trying to do here. Are you wishing to dynamically control the action or a form from within the same page via the drop downs, or are the drop downs on the previous page, selected, submitted, and processed into this page?
Posted: Thu Jul 22, 2004 3:01 am
by zeroanarchy
Thanks all for your help wondering if I could pick your brain a bit further.
ok well I tried that method and found that it came up with further problems the further I got into the code , so I have figured out a work around but I am stuck on something.
I have thre pages
Page 1
Customer enters their name and details
Page 2
Confirms the user name and details
Page 3
shows the users details again.
My problem is how do I make the orginal entry travel as far as the third page. I can make it go as far as page 2 but can not figure out how to make it travel to page3.
Code: Select all
//page 1
<input type="text" name="user" size="35">
//Page 2
Print "$user";
//Page 3
???
Posted: Thu Jul 22, 2004 3:28 am
by feyd
use sessions (:arrow: [php_man]session[/php_man]) on page 2 to store up the details for page 3.
Posted: Thu Jul 22, 2004 4:40 am
by zeroanarchy
Ok as you can guess I am fairly new at this, I tried the session option and cannot seem to get the value of user to show up on the form, can someone please help?
Cheers
zeroanarchy
Page 2
Code: Select all
<?PHP
Session_start();
?>
<html>
<head>
<title>New Page 2</title>
</head>
<body>
<?PHP
session_register("username");
$username == $user
?>
Page 3
Posted: Thu Jul 22, 2004 7:05 am
by markl999
Page2:
Page3:
Code: Select all
if(!empty($_SESSION['username'])){
echo $_SESSION['username'];
} else {
echo 'Username not set';
}
Posted: Thu Jul 22, 2004 9:44 pm
by zeroanarchy
Thanks everyone for your help, markl999 thanks for your help. I am still have a bit of a problem the session does not seem to be saving
Page 3 keep coming up with "Username not set", so I took the contents that you mentioned to palce in page 3 and instead added them to page2 just to see if the "username" field was working. I had no problems getting the username to print to the screen on page 2 but when I tried it on page 3 I only ever got "Username not set" and Ideas.
Here is the full code
Page1 code
Code: Select all
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Page 1</title>
</head>
<body>
<b>Full name</b>
<br>
<input type="text" name="user" size="35">
<html>
</body>
</html>
Page 2 code
Code: Select all
<html>
<head>
<title>New Page 2</title>
</head>
<body>
<?PHP
$_SESSIONї'username'] = $user;
if ($user==""){
Print "<b>Hi, our system tells us that you have forgot to enter the information correctly, can you hit the back button and fill in all the required fields!</b>";
} else {
Print "<br>$user<br>";
}
?>
<form action ="sent.php">
<input type="submit" value="Show name">
</body>
</html>
Page 3 code
Code: Select all
<html>
<head>
<title>Page 3</title>
</head>
<body>
<?PHP
Print "$username";
if(!empty($_SESSIONї'username'])){
echo $_SESSIONї'username'];
} else {
echo 'Username not set';
}
Cheers
zero
?>
</body>
</html>
Posted: Thu Jul 22, 2004 9:48 pm
by feyd
do you have session_start() on page 2 and 3? ...
Posted: Tue Jul 27, 2004 9:56 pm
by zeroanarchy
Thankyou all for your time and help.
Cheers
zeroanarchy