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!

I'm trying to make a page where I c

Status
Not open for further replies.

Roberti

Technical User
Joined
Mar 2, 2001
Messages
96
Location
NL
I'm trying to make a page where I can delete a record by clicking a link an passing the variable to the url:

<?php
include (&quot;./include/admin_inc.php&quot;);
include (&quot;./include/connection_inc.php&quot;);
include (&quot;./include/header_inc.php&quot;);

switch($_GET['actie'])
{
case &quot;delete&quot;:

//sql_delete = &quot;DELETE FROM tbl_failed_login WHERE failed_login_id = $_GET['failed_login_id']&quot;;

//$query_result = mysql_query($sql_delete,$strconnstring);

//echo mysql_error();

echo $_GET['actie'];

break;

default:

$sql_select = &quot;SELECT * FROM tbl_failed_login ORDER BY time&quot;;

$query_result = mysql_query($sql_select,$strconnstring);

echo mysql_error();

print &quot;<br>&quot;;
print &quot;<br>&quot;;
print &quot;<br>&quot;;
print &quot;<table border=0 widht=400 align=center>&quot;;
print &quot; <tr>&quot;;
print &quot; <td width=175 align=center><b>Time</b></td>&quot;;
print &quot; <td width=75 align=center><b>Username</b></td>&quot;;
print &quot; <td width=75 align=center><b>Password</b></td>&quot;;
print &quot; <td width=75 align=center><b>IP adres</b></td>&quot;;
print &quot; <td width=75 align=center><b>Delete</b></td>&quot;;
print &quot; </tr>&quot;;

WHILE ($row = mysql_fetch_object($query_result))
{
print &quot;<TR>&quot;;
print &quot; <TD width=175>&quot;.$row->time.&quot;</TD>&quot;;
print &quot; <TD width=75 align=center>&quot;.$row->username.&quot;</TD>&quot;;
print &quot; <TD width=75 align=center>&quot;.$row->password.&quot;</TD>&quot;;
print &quot; <TD width=75 align=center>&quot;.$row->ip_adress.&quot;</TD>&quot;;
print &quot; <TD width=75 align=center><a href=failed_login.php?failed_login_id=$row->failed_login_id&actie=delete>Delete</a></TD>&quot;;
print &quot;</TR>&quot;;
}

}

mysql_close($strconnstring);

print &quot;</table>&quot;;

include (&quot;./include/footer_inc.php&quot;);
?>

The first time that you get there the ?actie= is not in the url, and I get an error:

Notice: Undefined index: actie

How can I fix this?
 
perhaps this thread can also help you

thread434-733059 they use
Code:
if ($_GET['action'] == 'save')

which works fine also without ?actie

further I think that you're delete querie has to be
Code:
sql_delete = &quot;DELETE FROM tbl_failed_login WHERE failed_login_id =' $_GET['failed_login_id']'&quot;;
 
Code:
sql_delete = &quot;DELETE FROM tbl_failed_login WHERE failed_login_id = '$_GET['failed_login_id']'&quot;;

without the space ofcourse ;)
 
Thanx for the quick reply,

I've read that thread, but with both options I get the same error when ?actie= is not in the url.

As for the SQL statement, I get this error:

Parse error: parse error, unexpected '='

I can't fing anything on google fot this, can you help?
 
was that error with you're sql statement or with mine ??

ps you can also try by using the variable right away. so

Code:
if ($actie == 'save')
sql_delete = &quot;DELETE FROM tbl_failed_login WHERE failed_login_id ='$failed_login_id'&quot;;

and use code tags around you're code otherwise it's hard to tell what you're code exactly looks like [ code ][ /code ] but then without the space between the []
 
OK I've got the sql working, it was a very stupid mistake. I've forgotten the $ in front of sql_delete.

I've tried to use the variable directly, but it gave the same error.

when I type:
It works fine, but if I type:


I get the error:

Notice: Undefined index: actie
 
I've got it working now. I used:

IF(!isset($_GET['actie']))

So if the variable 'actie' is not there, display the page, elseif the variable 'actie' = delete, then delete the record.

Thanx for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top