Jump to content

Recommended Posts

why is it not updating?

 

<?php
$_POST['email'];
$_POST['submit'];
if (isset($_POST['submit']))
{ 
/*$sql =" UPDATE class_members SET email ='".$_POST['email']."', WHERE S_UID ='".$_POST['mem_id']."' ";*/
$result = mysql_query("UPDATE class_members SET email ='".$_POST['email']."', WHERE mem_id='".$_POST['mem_id']."'") 
or die(mysql_error());  
} 

?>

Link to comment
https://forums.phpfreaks.com/topic/209235-not-updating-query/
Share on other sites

You have a comma after setting the value of email but you're only updating 1 column, remove it.

 

$result = mysql_query("UPDATE class_members SET email ='".$_POST['email']."' WHERE mem_id='".$_POST['mem_id']."'") 
or die(mysql_error());  

Link to comment
https://forums.phpfreaks.com/topic/209235-not-updating-query/#findComment-1092622
Share on other sites

still it wont :-(

 

ok here is the whole page

 

<?php
//Start session
session_start();

//Check the session MEMBER_ID is present or not
if(!isset($_SESSION['S_UID']) || (trim($_SESSION['S_UID']) == '')) {
	header("location: access-denied.php");
	exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My Profile</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
$_POST['email'];
$_POST['submit'];
if (isset($_POST['submit']))
{ 
/*$sql =" UPDATE class_members SET email ='".$_POST['email']."', WHERE S_UID ='".$_POST['mem_id']."' ";*/
$result = mysql_query("UPDATE class_members SET email ='".$_POST['email']."' WHERE mem_id='".$_POST['mem_id']."'") 
or die(mysql_error());  
} 

?>

<h1>My Profile <?php echo $_SESSION['S_UID'];?></h1>
<a href="member-index.php">Home</a> | <a href="logout.php">Logout</a>
<p>This is another secure page. </p>
<form action="member-profile.php" method="post">
<input type="text" name="email" />
<input type="submit" value="update" />
</form>
</body>
</html>

 

what could possibly be wrong?

Link to comment
https://forums.phpfreaks.com/topic/209235-not-updating-query/#findComment-1092627
Share on other sites

the current code is this looks all ok but does not update anything in db. browser had been refreshed too

 

<?php
        require_once('config.php');
//Start session
session_start();

//Check the session MEMBER_ID is present or not
if(!isset($_SESSION['S_UID']) || (trim($_SESSION['S_UID']) == '')) {
	header("location: access-denied.php");
	exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My Profile</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
$_POST['email'];
$_POST['submit'];
if (isset($_POST['submit']))
{ 
/*$sql =" UPDATE class_members SET email ='".$_POST['email']."' WHERE mem_id='".$_POST['mem_id']."' ";*/
$result = mysql_query("UPDATE class_members SET email ='".$_POST['email']."' WHERE mem_id='".$_POST['mem_id']."'") 
or die(mysql_error());  
} 

?>

<h1>My Profile <?php echo $_SESSION['S_UID'];?></h1>
<a href="member-index.php">Home</a> | <a href="logout.php">Logout</a>
<p>This is another secure page. </p>
<form action="member-profile.php" method="post">
<input type="text" name="email" />
<input type="submit" name="submit" value="update" />
</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/209235-not-updating-query/#findComment-1092687
Share on other sites

@jesirose now it should be right?

 

$email = $_POST['email'];

if (isset($_POST['submit']))

{

print_r($_POST);

/*$sql =" UPDATE class_members SET email ='".$_POST['email']."', WHERE S_UID ='".$_POST['mem_id']."' ";*/

$result = mysql_query("UPDATE class_members SET email ='".$_POST['email']."' WHERE mem_id='".$_POST['mem_id']."'")

or die(mysql_error()); 

}

 

@PFM bro man now am i goin set the field name mem_id tell me please im now starting to give up. i guess there should be a hidden field to assign the mem_id? i do not know how to get it done at all :-(

Link to comment
https://forums.phpfreaks.com/topic/209235-not-updating-query/#findComment-1092712
Share on other sites

Where should mem_id be coming from?  Even if you have a hidden field for it, the value must come from somewhere, right?

 

It just seems like you're skipping steps.  Remember, you need to explicitly tell PHP to do everything you want to do.  In your head it's automatic to think that "oh, yeah, I'll match my query on the member's id."  PHP has no notion of that unless you tell it to do that.  Nothing is automatic.

Link to comment
https://forums.phpfreaks.com/topic/209235-not-updating-query/#findComment-1092717
Share on other sites

i tried this now

 

$email = $_POST['email'];
$mem_id = $_SESSION['S_UID'];
if (isset($_POST['submit']))
{ 
print_r($_POST); 

/*$sql =" UPDATE class_members SET email ='".$_POST['email']."', WHERE S_UID ='".$_POST['mem_id']."' ";*/
$result = mysql_query("UPDATE class_members SET email ='".$_POST['email']."' WHERE mem_id='".$_SESSION['mem_id']."'") 
or die(mysql_error());  

still now luck

Link to comment
https://forums.phpfreaks.com/topic/209235-not-updating-query/#findComment-1092725
Share on other sites

damn i did it :-) and it is updatng the field but is this the right way i did?

 

$email = $_POST['email'];

$mem_id['mem_id'] = $_SESSION['S_UID'];

if (isset($_POST['submit']))

{

print_r($_POST);

 

/*$sql =" UPDATE class_members SET email ='".$_POST['email']."', WHERE S_UID ='".$_POST['mem_id']."' ";*/

$result = mysql_query("UPDATE class_members SET email ='".$_POST['email']."' WHERE mem_id='".$mem_id['mem_id']."'")

or die(mysql_error()); 

}

 

i retrived the mem_id from the session where i stored it so i did it the right way?

Link to comment
https://forums.phpfreaks.com/topic/209235-not-updating-query/#findComment-1093006
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.