Bill Hanzel
Bill Hanzel

Reputation: 1

i am having problems passing a variable from a php page to another php page using a hyperlink

I had the code working at one time but i changed something and it quit working. The $id gets passed to the address bar on the browser but not to the next page. I used the session_start

while($row = mysql_fetch_array($resultd))
 {
$id = $row['id_num'];
echo "Edit  "; //ln68
echo "<a href='del.php?id_num = $id'>Delete</a>";
echo $row['id_num'] . " " . $row['first_name'] . " " . $row['last_name'] . ",&nbsp;&nbsp; " . $row['title'] . ",&nbsp;&nbsp; " . $row['city'] . ",&nbsp;&nbsp; " . $row['phone_pri'] . ",&nbsp;&nbsp; " . $row['email_addr'];

echo "

"; }

The receiving page is not getting the variable. I have used $_SESSION, $_GET, $_POST and nothing seems to work. I have even reversed the values in the href line and still nothing works. I used session_start here also.

this is page 2

$id = $_POST['id_num'];

// send query
$sql = 'delete FROM `delegate` WHERE `id_num`= $id';

Your comments would be most appreciated.

Upvotes: 0

Views: 156

Answers (1)

P2KA
P2KA

Reputation: 11

You are using GET request for passing the data via link

but in your second page, you are using POST

change it to $id = $_GET['id_num']; and try

and dont use spaces in href "

change it to "

space will be counted as a character

Upvotes: 1

Related Questions