craigtolputt Posted March 5, 2009 Share Posted March 5, 2009 Hi Guys, I have a flash form that enters a users email address into a database which works fine but i need to have another form that deletes their email address so i thought it would be something like... <?php include "connect.php"; $tableName = "usersv2"; $email = $_POST['email']; $insert = mysql_query("DELETE FROM $tableName (email) VALUES ('$email')"; $headers = "From: [email protected]\r\n"; $headers.= "Content-Type: text/html; charset=ISO-8859-1 "; $headers .= "MIME-Version: 1.0 "; $msg = "Thanks, your email address has been removed"; mail($email,"Thanks, your email address has been removed!",$msg,$headers); echo "&msgText=Email Removed!"; ?> This doesnt seem to work though any ideas?? Link to comment https://forums.phpfreaks.com/topic/148102-deleting-a-database-entry-help-please/ Share on other sites More sharing options...
waynew Posted March 5, 2009 Share Posted March 5, 2009 include "connect.php"; $tableName = "usersv2"; $email = mysql_real_escape_string($_POST['email']); $delete= mysql_query("DELETE FROM $tableName WHERE email = '$email'") or trigger_error(mysql_error()); if($delete== 1){ $headers = "From: [email][email protected][/email] "; $headers.= "Content-Type: text/html; charset=ISO-8859-1 "; $headers .= "MIME-Version: 1.0 "; $msg = "Thanks, your email address has been removed"; mail($email,"Thanks, your email address has been removed!",$msg,$headers); echo "&msgText=Email Removed!"; } Link to comment https://forums.phpfreaks.com/topic/148102-deleting-a-database-entry-help-please/#findComment-777419 Share on other sites More sharing options...
craigtolputt Posted March 5, 2009 Author Share Posted March 5, 2009 Thanks, thats done the trick... Do you know if its possible to check a table in a database for new entries then if there are new entries to send them as an email to all the email address's in another table?? Link to comment https://forums.phpfreaks.com/topic/148102-deleting-a-database-entry-help-please/#findComment-777433 Share on other sites More sharing options...
cooldude832 Posted March 5, 2009 Share Posted March 5, 2009 Store the date you last looked at it and then when u go to look query Where DateEntered is >= Last Look Date Link to comment https://forums.phpfreaks.com/topic/148102-deleting-a-database-entry-help-please/#findComment-777436 Share on other sites More sharing options...
craigtolputt Posted March 5, 2009 Author Share Posted March 5, 2009 What i thought was if i set a cron job up to run a php script once a week then the script can check a column in the news table like isNEW = 1 or something if it does equal 1 then the script will add it to an email and send that email out to my email address's in another table? Link to comment https://forums.phpfreaks.com/topic/148102-deleting-a-database-entry-help-please/#findComment-777441 Share on other sites More sharing options...
cooldude832 Posted March 5, 2009 Share Posted March 5, 2009 if date added isn't in there and doesn't need to be that is a logical solution However if you have dates use them becuse adding a field for something like that is bad practice when a better solution is there Link to comment https://forums.phpfreaks.com/topic/148102-deleting-a-database-entry-help-please/#findComment-777483 Share on other sites More sharing options...
craigtolputt Posted March 6, 2009 Author Share Posted March 6, 2009 Ah, ok. Sorry im not a PHP developer im a flash developer but need to try and get this done. So in the news table there are the following fields... newsid catalogid title content picture viewnum adddate rating ratenum source sourceurl isdisplay Link to comment https://forums.phpfreaks.com/topic/148102-deleting-a-database-entry-help-please/#findComment-777968 Share on other sites More sharing options...
craigtolputt Posted March 6, 2009 Author Share Posted March 6, 2009 Then in another table i have id email so i would like to run a script once a week which checks the adddate and then emails the news items for that week to the email address in the newsletter table. Link to comment https://forums.phpfreaks.com/topic/148102-deleting-a-database-entry-help-please/#findComment-777969 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.