₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,092 members, 8,420,279 topics. Date: Thursday, 04 June 2026 at 03:31 PM

Toggle theme

Help With Php Update Function - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingHelp With Php Update Function (750 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 PHPWithout Using Pow Function In C234

Mtnapp Developer Challenge 2013Is It Difficult?Can Some Ans This Pls