Click to See Complete Forum and Search --> : multiple pages in one file


PunkSktBrdr01
05-21-2003, 05:54 PM
I was wondering if it is possible to hold several e-mail pages in one PHP file and use PHP to determine which page to display based on a variable or hidden input on the parent page. This is what I've got so far:


<title>send stuff!</title>
<link rel="STYLESHEET" type="text/css" href="../popups/popup.css">
<font color=#F0F0F0>
<form action="mailthing.php" method="post">
<?php

if ($opinion) {
echo('
?>
<center>Hey, it's e-mail time!</center>
<br><br><br><br>
Which topic are you responding to?
<form action="mailthing.php" method="post">
<select name="subject">
<option value="response:society">Society
<option value="response:religion">Religion
</select>
<br><br>
Enter your opinions:
<br>
<textarea name="message" rows=10 cols=50></textarea>
<br><br>
<input type="submit" name="submit" value="I'm in for it, aren't I...">
<input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
</form>
<?
');
} elseif ($comment) {
echo('
?>
<br><br>
<center>Tell me whatchu think!</center>
<br><br>
<form action="mailthing.php" method="post">
<textarea rows=10 cols=50>Any ideas? Suggestions? Send 'em to me!</textarea>
<br><br>
<input type="submit" name="submit" value="lemme hear it...">
<input type="hidden" name="subject" value="comments">
<input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
</form>
<?
');
} elseif ($random) {
echo('
?>
<br><br>
<center>Randomness!</center>
<br><br>
Got a funny or bizarre quote? A strange story? An annoying habit of submitting stuff whenever you get the opportunity? Your search is over! Send it to me!
<br><br>
<form action="mailthing.php" method="post">
<textarea rows=10 cols=50>Tell me, tell me, tell me!</textarea>
<br><br>
<input type="submit" name="submit" value="well...">
<input type="hidden" name="subject" value="random">
<input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
</form>
<?
');
} else {
echo('
?>
<br><br>
<center>EMAIL APP</center>
<br><br>
<center>
To:<input type="text" name="mailto" length=15>
<br>
Subject:<input type="text" name="subject" length=10>
<br>
Message:<textarea rows=10 cols=50></textarea>
<br><br>
<input type="submit" name="submit" value="SEND EMAIL">
<br><br>
</form>
<?
');
}
?>


Any help is appreciated.

pyro
05-21-2003, 06:19 PM
This page shows a variation of that: http://www.infinitypages.com/research/divinclude.php. It basically sends a query string to the browser telling it which page to display. Could easily be modefied to just show certain parts of a page based on the query string.

PunkSktBrdr01
05-21-2003, 09:21 PM
I tried your suggestion, but I can't figure it out. I'm probably missing something obvious, but I just can't get it to work.
This is what I have so far:


<?php
if ($_SERVER["QUERY_STRING"] == "")
{
$include = "email/mailapp.php";
}
else
{
$include = $_SERVER["QUERY_STRING"];
}
include("$include");
?>
<title>send stuff!</title>
<link rel="STYLESHEET" type="text/css" href="../popups/popup.css">
<font color=#F0F0F0>
<?php
$opinion = echo('
?>
<center>Hey, it's e-mail time!</center>
<br><br><br><br>
Which topic are you responding to?
<form action="mailthing.php" method="post">
<select name="subject">
<option value="response:society">Society
<option value="response:religion">Religion
</select>
<br><br>
Enter your opinions:
<br>
<textarea name="message" rows=10 cols=50></textarea>
<br><br>
<input type="submit" name="submit" value="I'm in for it, aren't I...">
<input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
</form>
<?
');
$comment = echo('
?>
<br><br>
<center>Tell me whatchu think!</center>
<br><br>
<form action="mailthing.php" method="post">
<textarea rows=10 cols=50>Any ideas? Suggestions? Send 'em to me!</textarea>
<br><br>
<input type="submit" name="submit" value="lemme hear it...">
<input type="hidden" name="subject" value="comments">
<input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
</form>
<?
');
$random = echo('
?>
<br><br>
<center>Randomness!</center>
<br><br>
Got a funny or bizarre quote? A strange story? An annoying habit of submitting stuff whenever you get the opportunity? Your search is over! Send it to me!
<br><br>
<form action="mailthing.php" method="post">
<textarea rows=10 cols=50>Tell me, tell me, tell me!</textarea>
<br><br>
<input type="submit" name="submit" value="well...">
<input type="hidden" name="subject" value="random">
<input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
</form>
<?
');
$mailapp = echo('
?>
<br><br>
<center>EMAIL APP</center>
<br><br>
<form action="mailthing.php" method="post">
<center>
To:<input type="text" name="mailto" length=15>
<br>
Subject:<input type="text" name="subject" length=10>
<br>
Message:<textarea rows=10 cols=50></textarea>
<br><br>
<input type="submit" name="submit" value="SEND EMAIL">
<br><br>
</form>
<?
');
}
?>


Thanks!

pyro
05-21-2003, 09:26 PM
Ok, how about we use your original code? Shouldn't be too hard to get working. Just tell me when/under what circumstances the certain parts of the pages should be displayed, and I'll show you how to do it.

pyro
05-21-2003, 09:47 PM
Ok, I think maybe I know what you're trying to do... The main problem with your code is the echo statements. When you are moving in and out of PHP like you are, you don't use echo. The only other thing I changed was the way it calls the variables. I wrote it so it will work when global variables are turned off.

take a look at this code:

<title>send stuff!</title>
<link rel="STYLESHEET" type="text/css" href="../popups/popup.css">
<font color=#F0F0F0>

<form action="mailthing.php" method="post">

<?php
if ($_GET['opinion']) {
?>
<center>Hey, it's e-mail time!</center>
<br><br><br><br>
Which topic are you responding to?
<form action="mailthing.php" method="post">
<select name="subject">
<option value="response:society">Society
<option value="response:religion">Religion
</select>
<br><br>
Enter your opinions:
<br>
<textarea name="message" rows=10 cols=50></textarea>
<br><br>
<input type="submit" name="submit" value="I'm in for it, aren't I...">
<input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
</form>
<?
}
else if ($_GET['comment']) {
?>
<br><br>
<center>Tell me whatchu think!</center>
<br><br>
<form action="mailthing.php" method="post">
<textarea rows=10 cols=50>Any ideas? Suggestions? Send 'em to me!</textarea>
<br><br>
<input type="submit" name="submit" value="lemme hear it...">
<input type="hidden" name="subject" value="comments">
<input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
</form>
<?
}
else if ($_GET['random']) {
?>
<br><br>
<center>Randomness!</center>
<br><br>
Got a funny or bizarre quote? A strange story? An annoying habit of submitting stuff whenever you get the opportunity? Your search is over! Send it to me!
<br><br>
<form action="mailthing.php" method="post">
<textarea rows=10 cols=50>Tell me, tell me, tell me!</textarea>
<br><br>
<input type="submit" name="submit" value="well...">
<input type="hidden" name="subject" value="random">
<input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
</form>
<?
}
else {
?>
<br><br>
<center>EMAIL APP</center>
<br><br>
<center>
To:<input type="text" name="mailto" length=15>
<br>
Subject:<input type="text" name="subject" length=10>
<br>
Message:<textarea rows=10 cols=50></textarea>
<br><br>
<input type="submit" name="submit" value="SEND EMAIL">
<br><br>
</form>
<?
}
?>

to show first form, use a query string ?opinion=1 to show the second use a query string ?comments=1, etc

slimsam1
05-22-2003, 12:39 AM
or a switch...


<?
switch($_GET["p"]){
case "comment":
echo "Comment stuff";
echo "more comment stuff";
?> or you can do this <?
break;
case "other":
echo "other stuff";
echo "more stuff";
break;
default:
echo "oops, not a valid option";
}
?>


and you would link to

page.php?p=comment

or

page.php?p=other

:)