Page 1 of 1

Passing data between pages in PHP/HTML

Posted: Mon Feb 17, 2003 12:19 pm
by bmark
I am new to PHP development and I have run into a problem with passing data between pages.

on one page I have the code :-

print "<td>";
print "<form method=\"post\" action=\"delete.php?deleteid=100\">";
print "<input type=\"submit\" value=\"DELETE\">";
print "</form></td>";

in delete.php I have the following code:-

print $deleteid;

I just wanted to print the data to see if I am passing it correctly. I get the following error:-

Notice: Undefined variable: deleteid in C:\Inetpub\wwwcintrainc\delete.php on line 14

I though I had this correct but no matter what I try I cannot get the data to appear in the delete.php page.

WHAT AM I DOING WRONG???????

Posted: Mon Feb 17, 2003 12:48 pm
by daven
Read this thread:
viewtopic.php?t=511

You need to use $_GET['deleteid'] to access the variable. A better way to make the form would be:

using POST variables

Code: Select all

&lt;form action="delete.php" method="post"&gt;
&lt;input type="hidden" name="deleteid" value="100"&gt;
&lt;input type="submit" value="Delete"&gt;
&lt;/form&gt;
using GET variables

Code: Select all

&lt;form action="delete.php" method="GET"&gt;
&lt;input type="hidden" name="deleteid" value="100"&gt;
&lt;input type="submit" value="Delete"&gt;
&lt;/form&gt;

Code: Select all

<?php
print $_POST['deleteid']; // if POST form
print $_GET['deleteid']; // if GET form
?>

_get not working

Posted: Mon Feb 17, 2003 4:22 pm
by bmark
I tried the $_get function and now it says that _get is an unrecognized variable. Do I need to include something in my file for this function or use a .dll file??????

Posted: Tue Feb 18, 2003 2:16 am
by twigletmac
Did you use $_get or $_GET - PHP is case-sensitive therefore the two are totally different variables. $_GET is the correct one to use.

However, if this is what you used then it may be that you are using an older version of PHP - which version are you using?

Mac