Passing data between pages in PHP/HTML

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bmark
Forum Newbie
Posts: 9
Joined: Mon Feb 17, 2003 12:19 pm

Passing data between pages in PHP/HTML

Post 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???????
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post 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
?>
bmark
Forum Newbie
Posts: 9
Joined: Mon Feb 17, 2003 12:19 pm

_get not working

Post 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??????
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply