Home > Archive > PHP Programming > May 2004 > further on my fairly simple logic problem
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
further on my fairly simple logic problem
|
|
| Steve 2004-05-21, 10:31 am |
| > You can pass parameters in the URL for a POSTed form:
>
> ## page2
> <form method="post" action="page3.php?data=$urlencoded_data">
> <input type="text" name="address">
> <input type="submit">
> </form>
>
> ## page3
> mail('your_address@example.com', 'form data with contact details',
> "Someone entered this data:\n\n" .
> "{$_GET['data']}\n\n" .
> "The user details are:\n" .
> " address: {$_POST['address']}");
Thanks for all the previous help guys!
I'm halfway there, I think. I'm getting my POST data through to the
next page, but I'm not sure how or if I can use the URLENCODE command within
the form? Whereas I used to have the data passed on like so:
echo '<a href="mail.php?radiochoice=', urlencode($radiobutton),
'&radiomoderntrad=', urlencode($radiomoderntrad),
'&radiocoord=', urlencode($radiocoord),
'&radiopacking=', urlencode($radiopacking),
'&i1=', urlencode($item1),
'&i2=', urlencode($item2),
'&i3=', urlencode($item3),
'&i4=', urlencode($item4),
'&i5=', urlencode($item5),
'&i6=', urlencode($item6), ETC.
when I try to do a (obviously botched?!) cut and paste job to get the
following:
<form name="form1" method="post" action="finaltest.php?stevetest=",
urlencode($item1),' stevetest2=', urlencode($item2),'">
<p>
<input type="text" name="textfield">
</p>
<p>
<input type="submit" name="submit" value="Submit">
</p>
</form>?>
I get a 'Parse error: parse error, unexpected '<'' - yes, my grasp is syntax
is pretty crappy, but I'm no programmer - just a GFX guy trying to learn!
Anyone able to help me mastering this last piece of my jigsaw?
THANKS!
Steve
| |
| kingofkolt 2004-05-21, 1:30 pm |
| "Steve" <luckylucky200@hotmail.com> wrote in message
news:40ae0206$0$47310$c3e8da3@news.astraweb.com...
>
> Thanks for all the previous help guys!
>
> I'm halfway there, I think. I'm getting my POST data through to the
> next page, but I'm not sure how or if I can use the URLENCODE command
within
> the form? Whereas I used to have the data passed on like so:
>
> echo '<a href="mail.php?radiochoice=', urlencode($radiobutton),
> '&radiomoderntrad=', urlencode($radiomoderntrad),
> '&radiocoord=', urlencode($radiocoord),
> '&radiopacking=', urlencode($radiopacking),
> '&i1=', urlencode($item1),
> '&i2=', urlencode($item2),
> '&i3=', urlencode($item3),
> '&i4=', urlencode($item4),
> '&i5=', urlencode($item5),
> '&i6=', urlencode($item6), ETC.
>
> when I try to do a (obviously botched?!) cut and paste job to get the
> following:
>
> <form name="form1" method="post" action="finaltest.php?stevetest=",
> urlencode($item1),' stevetest2=', urlencode($item2),'">
> <p>
>
> <input type="text" name="textfield">
> </p>
> <p>
> <input type="submit" name="submit" value="Submit">
> </p>
> </form>?>
>
> I get a 'Parse error: parse error, unexpected '<'' - yes, my grasp is
syntax
> is pretty crappy, but I'm no programmer - just a GFX guy trying to learn!
> Anyone able to help me mastering this last piece of my jigsaw?
>
> THANKS!
>
> Steve
>
>
Steve --
You have HTML in the middle of a PHP block. What you would have do is take
the HTML form out of the PHP block and then put small PHP blocks in the
middle of the form action to print the urlencodes. Example:
<?php
// define $item's here:
$item1="foo";
$item2="bar";
?>
<form name="form1" method="post" action="finaltest.php?stevetest=<?php print
urlencode($item1); ?>&stevetest2=<?php print urlencode($item2); ?>">
<p>
<input type="text" name="textfield">
</p>
<p>
<input type="submit" name="submit" value="Submit">
</p>
</form>
hope this helped
- JP
| |
| Pedro Graca 2004-05-21, 2:31 pm |
| Steve wrote:
(snip)
> when I try to do a (obviously botched?!) cut and paste job to get the
> following:
Where is the initial php tag?
The one that refers to the last "?>" you posted?
> <form name="form1" method="post" action="finaltest.php?stevetest=",
> urlencode($item1),' stevetest2=', urlencode($item2),'">
> <p>
>
> <input type="text" name="textfield">
> </p>
> <p>
> <input type="submit" name="submit" value="Submit">
> </p>
> </form>?>
>
> I get a 'Parse error: parse error, unexpected '<''
Where?
> Anyone able to help me mastering this last piece of my jigsaw?
Try this:
<?php
echo '<form name="form1" method="post" action="finaltest.php?';
echo 'stevetest=', urlencode($item1), '&';
echo 'stevetest2=', urlencode($item2), '">';
echo '<p><input type="text" name="textfield"></p>';
echo '<p><input type="submit" name="submit" value="Submit"></p>';
echo '</form>';
?>
Or, as another poster said, separate the HTML from the PHP.
--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
| |
|
| > >
>
> Steve --
> You have HTML in the middle of a PHP block. What you would have do is take
> the HTML form out of the PHP block and then put small PHP blocks in the
> middle of the form action to print the urlencodes. Example:
>
> <?php
> // define $item's here:
> $item1="foo";
> $item2="bar";
> ?>
>
> <form name="form1" method="post" action="finaltest.php?stevetest=<?php
print
> urlencode($item1); ?>&stevetest2=<?php print urlencode($item2); ?>">
> <p>
>
> <input type="text" name="textfield">
> </p>
> <p>
> <input type="submit" name="submit" value="Submit">
> </p>
> </form>
>
> hope this helped
>
> - JP
>
Thanks JP - I will try this!! Your help really is appreciated!
again, thanks,
Steve
| |
|
| Thanks also to you Pedro - your help is invaluable to my ongoing efforts!
Steve!
"Pedro Graca" <hexkid@hotpop.com> wrote in message
news:2h6tgpF9dssbU1@uni-berlin.de...
> Steve wrote:
> (snip)
>
> Where is the initial php tag?
> The one that refers to the last "?>" you posted?
>
value="Submit">[color=darkred]
>
> Where?
>
>
> Try this:
>
> <?php
> echo '<form name="form1" method="post" action="finaltest.php?';
> echo 'stevetest=', urlencode($item1), '&';
> echo 'stevetest2=', urlencode($item2), '">';
> echo '<p><input type="text" name="textfield"></p>';
> echo '<p><input type="submit" name="submit" value="Submit"></p>';
> echo '</form>';
> ?>
>
> Or, as another poster said, separate the HTML from the PHP.
>
> --
> USENET would be a better place if everybody read: : mail address :
> http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
> http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
> http://www.expita.com/nomime.html : to 10K bytes :
|
|
|
|
|