₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,229 members, 8,510,792 topics. Date: Saturday, 31 October 2026 at 05:54 AM

Toggle theme

Help With Php Update Function - Programming - Nairaland

Nairaland Forum › Science/Technology › Programming › Help With Php Update Function (769 Views)

1 Reply

Help With Php Update Function by charliebiz(op): 5:03pm On Apr 23, 2013
I created this function to update a database
when the submit button is click but it seems not to work.

please I need help debugging it.

<?php
include_once('libraries.php'); // contains the database function

function update(){
db(); // database function
$pname = $_POST['pname'];
$categoryid = $_POST['categoryid'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$user = $_POST['users'];
$pass = $_POST['pass'];

function createSalt()
{
$string = md5(uniqid(rand(), true));
return substr($string, 0, 3);
};
$salt = createSalt();
$hash = hash('sha256', $salt . $pass);

$sql = "UPDATE users SET user=?,pass=?,salt=?,pname=?,email=?,phone=? WHERE categoryid=?";
$q = $conn->prepare($sql);
$q->execute(array($user,$hash,$salt,$pname,$email,$phone,$categoryid));
}

?>
Re: Help With Php Update Function by jacob05(m): 8:05pm On Apr 23, 2013
I think you should have something like

if (isset($_POST["name of Your Submit Button"]){
update();
}

and the createSalt() function should be declared outside the update function....
Re: Help With Php Update Function by prodam(m): 10:16am On Apr 24, 2013
itz nt working?...whatz d error?..nothin seems 2 b wrong with this code snippet..if this is the action file of ur form, and all field names are correct, then there shuld be no bug or even mosquitoe...
1 Reply

Sorting Out A Simple Text Dictionary With PHP • Without Using Pow Function In C • 2 • 3 • 4

Ssh Needed • Apps Developer Wanted: Finance Category: Budget-$500-700 • How To Protect Nairaland From Hackers Attack