Jump to content

Edit Multiple fields


fantic

Recommended Posts

Something like this:

 

edit.php

<?php
$theuID = 1;

if(isset($_POST['submit'])) {
foreach($_POST as $key=>$value) {
	$$key = $value;
}
$sqlupdate = "UPDATE tbluser SET firstname = '$firstname', lastname = '$lastname' WHERE uID = '$uID'";            
$result = mysql_query($sqlupdate);
header('Location: edit.php');
}

$sql = mysql_query("SELECT uID,firstname,lastname FROM tbluser WHERE uID = $theuID");
$row = mysql_fetch_array($sql);

echo '
<html>
<head>
<title>Form</title>
</head>
<body>
<form action="edit.php" method="post">
<input type="hidden" name="uID" value="'.$row['uID'].'" />
<input type="text" name="firstname" value="'.$row['firstname'].'" />
<input type="text" name="lastname" value="'.$row['lastname'].'" />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>';
?>

Link to comment
https://forums.phpfreaks.com/topic/129555-edit-multiple-fields/#findComment-671676
Share on other sites

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.