| | |
Delete function acts unexpectedly
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2008
Posts: 40
Reputation:
Solved Threads: 0
Hello!
I have a small problem with a MySQL query inside a PHP site. If a user clicks "Yes" to delete a record, the record should be deleted (which works great)
However, when the user clicks "No", it should redirect the user to another location, leaving the record intact...but it redirects the user AND deletes the record anyway.
What am I overlooking?
Thank you in advance for any assistance!!
- Jim
I have a small problem with a MySQL query inside a PHP site. If a user clicks "Yes" to delete a record, the record should be deleted (which works great)
However, when the user clicks "No", it should redirect the user to another location, leaving the record intact...but it redirects the user AND deletes the record anyway.
What am I overlooking?
Thank you in advance for any assistance!!
- Jim
PHP Syntax (Toggle Plain Text)
require_once('mysql_connect.php'); if(isset($_POST['submitted'])){ if($_POST['sure'] == "Yes") { echo $_POST['submitted']; $query = "delete from movie_users where movie_users_id = '$id'"; $result = @mysql_query ($query); header("Location: current_users.php"); echo "User deleted successfully"; } elseif($_POST['sure'] == "No") { header("Location: not_deleted.php"); } } ?> <body> <form action="delete_user.php" method ="post"> <div id="main"> <p><?PHP echo "Are you sure you want to delete user $fl_name"; ?> </p> <input type = "radio" name = "sure" value = "Yes" /> Yes <input type = "radio" name = "sure" value = "No" /> No</p> <p><input type = "submit" name = "submit" value = "submit" /> </p> <input type = "hidden" name = "submitted" value = "TRUE" /> <input type = "hidden" name = "id" value = "<?php echo $id; ?>" /> </form> </body> </div> mysql_close(); <?php include('footer.php'); ?>
•
•
Join Date: Oct 2008
Posts: 40
Reputation:
Solved Threads: 0
Oh! I found the error myself! /smackhead
<form action="delete_user.php" method ="post">
needed to be
<form action="delete_user1.php" method ="post">
I forgot that I had changed the name of the file to do some other work on it while keeping the integrity of the first file incase the changes didn't work.
Thank you!
But what is wrong with my close tag?
<form action="delete_user.php" method ="post">
needed to be
<form action="delete_user1.php" method ="post">
I forgot that I had changed the name of the file to do some other work on it while keeping the integrity of the first file incase the changes didn't work.
Thank you!
But what is wrong with my close tag?
see here , you have started a div like this :
But You have to Ends it like
Instead of
PHP Syntax (Toggle Plain Text)
<body> <form action="delete_user.php" method ="post"> <div id="main">
PHP Syntax (Toggle Plain Text)
</div></form></body>
PHP Syntax (Toggle Plain Text)
</form> </body> </div>
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
•
•
Join Date: Oct 2008
Posts: 40
Reputation:
Solved Threads: 0
Thank you for pointing out the error I didn't even see.
Everything seemed to work properly the way that I had it before, so I guess my question is...is it just good practice to close them in the reverse order you opened them, or does it really make a difference that just didn't happen to appear in this particular instance?
Thank you again
- Jim
Everything seemed to work properly the way that I had it before, so I guess my question is...is it just good practice to close them in the reverse order you opened them, or does it really make a difference that just didn't happen to appear in this particular instance?
Thank you again
- Jim
•
•
•
•
Thank you for pointing out the error I didn't even see.
Everything seemed to work properly the way that I had it before, so I guess my question is...is it just good practice to close them in the reverse order you opened them, or does it really make a difference that just didn't happen to appear in this particular instance?
Thank you again
- Jim
<tagopen><innertag>blah blah</innertag></tagopen> = TagOpen CONTAINS innertag CONTAINS text
NOT
<tagopen><innertag>blah blah</tagopen></innertag> = TagOpen CONTAINS START innertag CONTAINS text, END TagOpen
Last edited by ShawnCplus; May 5th, 2009 at 12:02 pm.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
![]() |
Other Threads in the PHP Forum
- Previous Thread: MySQL Question ...
- Next Thread: Wanted Help ,urgently with PHP and Ajax
| Thread Tools | Search this Thread |
# 5.2.10 action address apache api array auto autoincrement beginner binary broken cakephp checkbox class classes cms code cron curl database date dehasher destroy display dissertation domain dynamic echo echo$_get[x]changingitintovariable... email error errorlog fatalerror file files folder form forms function functions google href htaccess html if-else image images include insert ip javascript joomla legislation limit link load login mail masterthesis menu mlm multiple mysql mysqlquery oop open paypal pdf persist php popup problem query radio random record recursion remote script search server sessions sms sockets source space sql syntax system table tutorial update upload url validator variable video web youtube






