Post by Jeens » Sat Aug 08, 2020 4:44 am

Hello there,
I have a little question, for those that know a bit about mysql and php.
I have a code snippet that does two things.

1.) lets people who are not registred users unsubscribe from our newsletter (their emails are stored in the oc_newsletter table in the field email
2.) lets people who are registred users unsubscribe from the newsletter

What i want is, that it removes "guest" subscribers from not only oc_newsletter, but also from another table, oc_guest_newsletter. In oc_guest_newsletter the emails are stores in guest_email.

Why i need it? I have two modules collecting email adresses and writing them to their respective table and i want to use one script for users to be able to unsubscribe.
I hope you all understand what i want. I think it comes down to the first line of the code below:

Code: Select all

			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "newsletter WHERE md5(CONCAT('newsletter', email)) = '" . $this->db->escape($this->request->get['id']) . "'");
			
			$query1 = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE md5(CONCAT('newsletter', email)) = '" . $this->db->escape($this->request->get['id']) . "'");

			if ($query->num_rows) {
				$this->db->query("DELETE FROM " . DB_PREFIX . "newsletter WHERE email = '" . $this->db->escape($query->row['email']) . "'");
				
				$data['text_message'] = sprintf($this->language->get('text_message'), $query->row['email']);
			} elseif  ($query1->num_rows) {
				$this->db->query("UPDATE " . DB_PREFIX . "customer SET newsletter = '0' WHERE email = '" . $this->db->escape($query1->row['email']) . "'");
				
				$data['text_message'] = sprintf($this->language->get('text_message'), $query1->row['email']);
			} else {
				$data['text_message'] = $this->language->get('error_unsubscribe');
			}		

Newbie

Posts

Joined
Sat Jul 11, 2020 5:16 pm

Post by IP_CAM » Sat Aug 08, 2020 8:00 am

Well, you're talking about unknown to others 'Code Snippets' and
'Modules', but how should someone else know, how they do theirJob,
in order to give you some advise ? ??? And how about the OC Version
and Theme you use, it's just not gonna work this way ...
Ernie

Please don't send me OC Forum Personal Messages, just contact: jti@jacob.ch
---
OC 1.5.6.5 LIGHT Test Site: http://www.bigmax.ch/shop/
OC 1.5.6.5 V-PRO Test Site: http://www.openshop.li/shop/
My Github OC Site: https://github.com/IP-CAM
2'600+ FREE OC Extensions on the World's largest Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by paulfeakins » Mon Aug 10, 2020 5:40 pm

If no one does this bit of work for free you could pay a developer such as ourselves or post a job in the Commercial Support Forum.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Guru Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom
Who is online

Users browsing this forum: No registered users and 16 guests