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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.