little help with this code
#1

Hey all, im making, like you announced before, a game server control panel, but im making the "change password and e-mail section"
And i do not know why, the code is not deleting the data on the mysql database.

This is my code:

PHP код:
$query1 "DELETE FROM samp WHERE password = ('$password')"
$result mysql_query($query1); 
$query2 "DELETE FROM samp WHERE email = ('$email')"
$result mysql_query($query2); 
// now we insert it into the database 
$insert "INSERT INTO samp (password, email) 
VALUES ('"
.$_POST['email']."', '".$_POST['password']."')"
$add_member mysql_query($insert); 
Any help for this?
Thank you.
Reply
#2

PHP код:
"DELETE FROM samp WHERE password = ('" $password "')" 
Although that little bit of code you posted doesn't make any sense to me at all. Maybe you better look at MySQL's UPDATE syntax.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
PHP код:
"DELETE FROM samp WHERE password = ('" $password "')" 
Although that little bit of code you posted doesn't make any sense to me at all. Maybe you better look at MySQL's UPDATE syntax.
Thank you.
Reply
#4

So you remove 2 fields, then add them again, if I may ask, why? perhaps you should use the UPDATE command:

PHP код:
// Update the fields
$update "UPDATE `samp` SET `email` = '".$_POST['email']."', `password` = '".$_POST['password']."'"
$result mysql_query($update); 
This does exactly the same thing as the code you posted, but a LOT faster.
Reply
#5

Quote:
Originally Posted by Sinner
Посмотреть сообщение
So you remove 2 fields, then add them again, if I may ask, why?
It doesn't just remove fields, it deletes the whole row, or even multiple rows if you're not careful.
Reply
#6

Well, this is still not working.

This is my "full" include code

PHP код:
<?php  

mysql_connect
("hostname""username""password") or die(mysql_error());  
mysql_select_db("database_name") or die(mysql_error());  

if (isset(
$_POST['update'])) {  

if (!
$_POST['email'] | !$_POST['password']) { 
die(
'You did not complete all of the required fields'); 


if (
$_POST['security'] != "yes")
{
    die(
'The security password is wrong. '); 
}

$_POST['password'] = md5($_POST['password']); 
if (!
get_magic_quotes_gpc()) {  
$_POST['email'] = addslashes($_POST['email']); 


$update "UPDATE `samp` SET `email` = '".$_POST['email']."', `password` = '".$_POST['password']."'"
$result mysql_query($update);
?>
Password sucefully changed!
<?php  
}  
else  
{  
?> 
Please fill the field below, password and e-mail are needed.
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> 
<table border="0"> 
<tr><td>Password: *</td><td> 
<input type="text" name="password" maxlength="10"> 
</td></tr> 
<tr><td>e-mail</td><td> 
<input type="text" name="email" maxlength="20"> 
</td></tr>  
<tr><td>Security, please write "yes"</td><td> 
<input type="text" name="security" maxlength="20"> 
</td></tr>  
<tr><th colspan=2><input type="submit" name="submit" value="update"></th></tr> </table> 
</form> 
* The password is show.
<?php 

?>
Reply
#7

Bump
I have done some changes and the code still not works.
Reply


Forum Jump:


Users browsing this thread: 7 Guest(s)