Jump to content

Need a simple Amend and Delete code


ntin0s

Recommended Posts

Hello,

 

I am a new user here and new in php coding also. I am a student and i have this task to create a simple website and I am stacked at the Amend and Delete data, so i could really use any help asap. I really need your help because i have to finish this now. I have this search.php that searches my users and displays the user-names and next to them an Amend and a Delete button

the links are like this:

echo "<a href=:\"amend.php?id=" . $a_row['username'] . "\">Amend user</a>";

echo "<span> </span>";

echo "<a href=:\"delete.php?id=" .$a_row['username'] . "\">Delete user</a>"

 

what code should i have in amend.php to make this work?

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/219244-need-a-simple-amend-and-delete-code/
Share on other sites

on my search users i have this link

"<a href=:\"amend_form.php?id=" . $a_row['username'] . "\">Amend user</a>"

 

the amend_form.php is like this

    <html>

<body>

<H1>Amend existing user<H1>

 

<form action="Amend.php" method="post">

Username: <input type="text" name="username"value="<?=$keywords?>"">

<input type="submit" value="Amend"

</form>

 

</body>

</html>

 

and the amend.php

 

<?$keywords = $_POST['keywords'];

setcookie("keywords", $keywords);

?> 

<?php

$con = mysql_connect("localhost","*****","*****");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("******", $con);

 

$sql="UPDATE Users

SET username='$_POST[username]' WHERE username='$_POST[keywords]'";

 

if (!mysql_query($sql,$con))

  {

  die('Error: ' . mysql_error());

  }

echo "User details successfully updated";

 

mysql_close($con)

?>                     

 

Everything is messud up and i really need some help

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.