Re: external method and forms

murat bilal <[email protected]>
Newsgroups gmane.comp.web.zope.general
Message-ID <CAMRfwGsg7eQX-Y6ZW7PezgcxC9OMXyBkNwmDdCwzApO2veLqKg@mail.gmail.com>
At last I find and change everything.Now it looks like this:
------MY DTML DOCUMENT-----
<form action="" method="post"><br />
<p><br> KULLANICI ADI <br> <input type="text" name="name">
<p><br> SIFRE<br> <input type="text" name="sifre">
<p><br> SIFRE YENIDEN<br> <input type="text" name="sifret">
 <input type="submit" name="formParams:action" value="degistir">
</form>

----MY EXTERNAL PYTHON METHOD------
import crypt
import MySQLdb
def formParams(self,name,sifre,sifret):
  conn = MySQLdb.connect(host="localhost",
                       user = "xxxx",
                       passwd = "yyyy",
                       db = "xxxzzz")
  cursor = conn.cursor()
  self.name=name
  self.sifre=sifre
  self.sifret=sifret
  if sifre == sifret:
    cryp = crypt.crypt(sifre,'mysecret')
    cursor.execute("""update mytable set PASS_WORD=%s where
USERNAME=%s""",(cryp,name))
    return "BASARI ILE DEGISTIRILDI"
  else:
    return "Sifreler uyusmadi.Tekrar deneyiniz."
  cursor=conn.close()


On Mon, Jan 7, 2013 at 11:16 PM, Mike Cullerton <plone-Jyq08SUepVWvlIlDamLRIwC/[email protected]>wrote:

> It looks like you missed some quotes.
>
> this line
>   cryp = crypt.crypt(sifre,'mysecret')
>
> should probably be
>   cryp = crypt.crypt('sifre','mysecret')
>
> Mike
>
> On Jan 7, 2013, at 1:33 PM, murat bilal <[email protected]> wrote:
>
> Hi,
>
> I try to make a simple paswd recovery page for my site.Username and
> password stored in mysql db.My DTML document is:
> <form action="deg" method="POST">
>  <h2>Şifre değiştirme sayfasına hoşgeldiniz<h2>
> <br>
>   KULLANICI ADI: <br><input type="text" name="name:ignore_empty"></br>
> <p><br>  ŞİFRE: <br> <input type="text" name="sifre:ignore_empty"></br>
> <p><br>  ŞİFRE TEKRAR: <br> <input type="text"
> name="sifret:ignore_empty"></br>
> <p><br>  <input type="submit" value="yenile" align="center" >
> <dtml-var "deg(REQUEST)">
> </form>
>
> and my external python method is as follows:
>
> import crypt
> import MySQLdb
> conn = MySQLdb.connect(host="localhost",
>                        user = "rxxxx",
>                        passwd = "yyyy",
>                        db = "zzzz")
> cursor = conn.cursor()
> #return context.responseMessage()
> def deg(self):
>
>   cryp = crypt.crypt(sifre,'mysecret')
>   if request.form["sifre"] == request.form["sifret"]:
>     cursor.execute("""update mytable set PASS_WORD=%s where
> USERNAME=%s""",(cryp,name))
>     print "SUCCESS"
>   else:
>     print "please try again!"
> cursor=conn.close()
> But when i tested from DTML Document I got this error
>
> *Error Type: NameError*
> *Error Value: global name 'sifre' is not defined*
>
> Can anybody help me?
>
> Regards
>
> MuratB
>
>
>
> _______________________________________________
> Zope maillist  -  [email protected]
> https://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
> https://mail.zope.org/mailman/listinfo/zope-announce
> https://mail.zope.org/mailman/listinfo/zope-dev )
>
>
>

_______________________________________________
Zope maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.