Help with a bit of PHP

For everything that's not in any way related to PureBasic. General chat etc...
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Help with a bit of PHP

Post by netmaestro »

I'm trying to call a php script with 3 parameters. I'm trying to do it like this:
echo "<form method='post' action='newsale.php?cost='.$cost.'&id='.$id.'&details='.$details>";
and it just dies. Doesn't do anything. I was once quite strong in this stuff but I haven't seen it for four years now and I'm rusty. And confused. Seems to me this ought to work. Can someone tell me:

a) why it fails
b) am I even going about it in the right manner
c) how the (*!!??%%) am I going to pass these 3 parameters to the script with no fuckups

Anyone who can shed light or help with this, I will be in your debt. I've been on these boards for 14 years and I know one thing above all: some of the brightest lights on the planet are right here. So I'll relax knowing that someone will point me in the right direction. Thanks so much.
BERESHEIT
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4662
Joined: Sun Apr 12, 2009 6:27 am

Re: Help with a bit of PHP

Post by RASHAD »

Hi NM,

You were actually closing off the attribute instead of the entire echo before appending your vars. This should fix it:

Code: Select all

echo "<form method='post' action='newsale.php?cost=".$cost."&id=".$id."&details=".$details."'>";
You could instead opt for using a header call instead of echoing out a form, depending on what it is exactly you're trying to do:

Code: Select all

header("Location:newsale.php?cost=$cost&id=$id&details=$details");

Rashad Junior.
Last edited by RASHAD on Sun Apr 28, 2019 2:36 am, edited 1 time in total.
Egypt my love
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Help with a bit of PHP

Post by netmaestro »

Thank you so much RASHAD. In a few hours I'll be where I can test. What is your rank on these boards? If it's less than 'Expert' I'll speak with Fred.
BERESHEIT
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Help with a bit of PHP

Post by #NULL »

There is still a ." missing in RASHAD's first snippet, must be $details."'>";
But I would rather use input fields for all parameters. You can use hidden fields, too.

Code: Select all

$id = 111;
$cost = 2.22;
$details = "Our whole wheat bread has a rich wheat flavour with a hint of molasses.";

print '<pre>$_POST:' . print_r($_POST, true) . '</pre>';
print '<pre>$_GET:' . print_r($_GET, true) . '</pre>';

echo "<form method='post' action='test.php'>";
echo "<input type='hidden' name='id' value='".$id."' />";
echo "<input type='text' name='cost' value='".$cost."' />";
echo "<input type='text' name='details' value='".$details."' />";
echo "<input type='submit' name='submit' />";
echo "</form>";
Post Reply