Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Parm in URL with PHP

Status
Not open for further replies.

USADarts

Programmer
Dec 20, 2004
21
US
First, is this correct to pass the parms name and nameid?
<form action="tournaments.php?$name&$nameid" method="POST">

Second, on the tournament.php page, how to I go about retrieving the name and nameid value to use?
I have tried:
var pname = getParameter("name");
var pnameid = getParameter("nameid");

Not working

Thanks
David

 
<form action="tournaments.php?mname=$name&nameid=$nameid" method="POST">

Known is handfull, Unknown is worldfull
 
Receiving the following error:

Parse error: parse error, unexpected T_VAR in /home/hascupd/public_html/members/tournaments.php on line 9


Line 9 code is this:
var pname = getParameter("name");
 
Still Getting same error:
Parse error: parse error, unexpected T_VAR in /home/hascupd/public_html/members/tournaments.php on line 9


tournaments.htm
<form action="tournaments.php?name=$name&nameid=$nameid" method="POST">


tournaments.php
<?php
var $pname = getParameter("name");
var $pnameid = getParameter("nameid");
....
 
Are you invoking "var" outside of a class definition? That's a no-no.

If you want to instantiate a bare variable and assign it a value, just do:

$pname = getParameter("name");




Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thank you very much for the help. I am fairly new at some of the PHP procedures. However, I am know receiving the following error:

Fatal error: Call to undefined function: getparameter() in /home/hascupd/public_html/members/tournaments.php on line 9

 
Is getParameter your own function or is it just what you think it should be. I see no reference of that function in the manual. Have you tried?
Code:
$pname = $_POST["name"];
 
Please forgive me if there is something I'm not seeing here..
(Very likely(Sincerely)).

But I think USADarts is trying to parse data in an .htm file.
If you want values there you have to parse it thru php
Like:

tournamentsa.php
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <title></title>
  
</head>
<body>
<?php
$name = "Fred";
$nameid = 15;

echo "<form action=\"tournamentsb.php?name={$name}&nameid={$nameid}\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"name\" value=\"{$name}\">\n";
echo "<input type=\"hidden\" name=\"nameid\" value=\"{$nameid}\">\n";
?>

<input type="submit">
</form>
</body>
</html>

tournamentsb.php
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <title></title>
</head>
<body>
<?php
echo "Hello ". $_GET['name']. "<br>\n";
echo "Your id is ". $_GET['nameid']. "<br>\n";

//But you can use the hidden form fields also that were "posted"
echo "Hello ". $_POST['name']. "<br>\n";
echo "Your id is ". $_POST['nameid']. "<br>\n";

?>
</body>
</html>

You use $_GET["name"] and $_GET["nameid"] to retreive the url parameters.
For "posted" parameters $_POST["name"] and $_POST["nameid"].

Thanks,
 
Ok, this is what I am trying to do going back a few steps.
name = David Hascup
nameid = usadarts

profile.php - link passing 2 fields from an sql database
Code:
<a href="[URL unfurl="true"]http://www.usadarts.com/members/tournaments.htm?$name&$nameid">[/URL]

tournaments.htm
Code:
<html>
<head><title></title>
</head>
<body>
<center>
<form action="tournaments.php?htmname=$htmname&nameid=$nameid" method="POST"> 
......

tournaments.php -
Code:
<?php 
$phpname = $_GET['htmname'];
$phpnameid = $_GET['htmnameid'];
this then updates a seperate sql database
Code:
$insert = "INSERT INTO results (name, username, points) 
VALUES ('$phpname', '$phpnameid', '$pts')";

I am getting no more erro message, however the following is ending up in the SQL database:
name field = $htmname instead of David Hascup
username field = $htmnameid instead of usadarts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top