aboutsummaryrefslogtreecommitdiff
path: root/supression.py
blob: 01ac3fba3e13016a5b13b11e0696c4dd959b5bdb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/python
# -*- coding: utf-8 -*-

from mod_python import Session, util
from fonctions import redirectionSiNonConnecte, lien, codeHTML, connexionBD

def index(req):
    req.content_type="text/html"

    sess = Session.Session(req)
    redirectionSiNonConnecte(req,sess)
    id_util=sess["id_util"]
    id_contact=req.form["id_contact"]
    conn = connexionBD()
    cur = conn.cursor()

    sql = "select * from contact where id_contact={} and id_util={};".format(id_contact, id_util)
    cur.execute(sql)
    conn.commit()
    data = cur.fetchall()
    

    if not data:
        req.write(codeHTML("Erreur !", """
<p>Ce contact ne vous appartient pas.</p>
""" + lien('menu.py',"Retour au menu")))
	conn.close()
    else:
	sql = "delete from contact where id_contact={};".format(id_contact)
	cur.execute(sql)
	conn.commit()
	conn.close()
	util.redirect(req, "liste.py")