[PHP] MySQL, MD5 and SHA1
provided I want to store hash of a password in MySQL ... Using MySQL, the whole check can be achieved with a SQL query, since the MD5 function is provided as part of the database query language ... Can I use also SHA1 or must I use MD5? Thanks in advance, -- When the sun rises I receive and when it sets I forgive -> http://users.skavt.net/~gleskovs/ All the Love, Grega Leskov'sek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how to write element in textarea?
I am writing CMS, that will be able to edit files. For editing I put file inside textarea, but when I open file that has textarea element inside it I lose (read: don't show data in the textarea element.) the data after the inside element. Any suggestions how can I fix this? Thanks in advance, -- When the sun rises I receive and when it sets I forgive -> http://users.skavt.net/~gleskovs/ All the Love, Grega Leskov'sek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how to delete part of string
I have a POST string field and I want to skip some & fields before &id= How do I simply delete operation=nekaj&price=fddf&id=de&id=ta ... into &id=de&id=ta ... Thanks in advance, -- When the sun rises I receive and when it sets I forgive -> http://users.skavt.net/~gleskovs/ All the Love, Grega Leskov'sek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to delete part of string
No, I used POST and manage the data through a stream: if ($fp = fopen("php://input", 'r')) { $content = ''; // keep reading until there's nothing left while ($line = fgets($fp)) { $content .= $line; } } Please advice on the matter. All the Love, Grega from Slovenia 2009/5/23 Marc Steinert : > I guess you mean GET parameters instead of POST. > > $string = preg_replace('/^(.*?)&id=/', '&id=', $_SERVER['QUERY_STRING']); > > Don't know, if that's exactly what you wanted. > > Greetings from Germany > > Marc > > > Grega Leskovsek wrote: >> >> I have a POST string field and I want to skip some & fields before &id= >> How do I simply delete >> operation=nekaj&price=fddf&id=de&id=ta ... >> into >> &id=de&id=ta ... >> >> Thanks in advance, > > > -- > Synchronize and share your files over the web for free > http://bithub.net/ > > My Twitter feed > http://twitter.com/MarcSteinert > > > > > -- When the sun rises I receive and when it sets I forgive -> http://users.skavt.net/~gleskovs/ All the Love, Grega Leskov'sek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] getting file location
I have made a CMS with editing files. When I display the file name it shows something like "../subdir/filename.php" How can I display the actual filename that's on the web: like http://localhost/subdir/filename.php or even better if it is possible: http://domainname/subdir/filename.php ? Thanks in advance, Grega from Slovenia -- When the sun rises I receive and when it sets I forgive -> http://users.skavt.net/~gleskovs/ All the Love, Grega Leskov'sek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql create table with date or timestamp
CREATE TABLE diary(iddiary int auto_increment not null, imepriimek varchar(50), when date("%T%W%e%c%y"), action varchar(30), onfile varchar(100) unique id(iddiary)); I tried the above and it didn't work. What must I do to create a table with full time and date. If I should use timestamp how do I convert thee timestamp in php back to "normal" time? (I also tried the mysql command: when timestamp and when date in the above first mysql clause but it didnt work ) Please help me. Thanks in advance, -- When the sun rises I receive and when it sets I forgive -> http://users.skavt.net/~gleskovs/ All the Love, Grega Leskov'sek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql create table with date or timestamp
I GOT THIS ERROR when I tried first sample with when timestamp; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual thatcorresponds to your MySQL server version for the right syntax to use near 'id(iddiary) )' at line 1 2009/5/28 João Cândido de Souza Neto : > If you need date and hour the best way is: > > CREATE TABLE diary ( >  iddiary int auto_increment not null, >  imepriimek varchar(50), >  when timestamp, >  action varchar(30), >  onfile varchar(100) >  unique id(iddiary) > ); Please advice. Thanks in advance, Grega > > if you need only date you can use: > > CREATE TABLE diary ( >  iddiary int auto_increment not null, >  imepriimek varchar(50), >  when date, >  action varchar(30), >  onfile varchar(100) >  unique id(iddiary) > ); > > To get formated date you should use: > > select date_format(when, "%T%W%e%c%y") from diary; > > To put data in this field you can use: > > insert into diary (when) values (str_to_date("10:55:14Thursday28509", > "%T%W%e%c%y")); > > > > -- > João Cândido de Souza Neto > SIENS SOLUÃÃES EM GESTÃO DE NEGÃCIOS > Fone: (0XX41) 3033-3636 - JS > www.siens.com.br > > "Grega Leskovsek" escreveu na mensagem > news:1df2d4810905280643y62a0f092p91fa2c57558d8...@mail.gmail.com... >> CREATE TABLE diary(iddiary int auto_increment not null, imepriimek >> varchar(50), when date("%T%W%e%c%y"), action varchar(30), onfile >> varchar(100) unique id(iddiary)); >> >> I tried the above and it didn't work. What must I do to create a table >> with full time and date. If I should use timestamp how do I convert >> thee timestamp in php back to "normal" time? (I also tried the mysql >> command: >> when timestamp >> and >> when date >> in the above first mysql clause but it didnt work >> ) >> >> Please help me. Thanks in advance, >> -- >> When the sun rises I receive and when it sets I forgive -> >> http://users.skavt.net/~gleskovs/ >> All the Love, Grega Leskov'sek > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- When the sun rises I receive and when it sets I forgive -> http://users.skavt.net/~gleskovs/ All the Love, Grega Leskov'sek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql create table with date or timestamp
The problem was I didn't type a comma before unique id(iddary). Thanks to everybody for helping me on the seminar. Love, Grega 2009/5/28 LinuxManMikeC : > Actually, AUTO_INCREMENT is the correct syntax for MySQL.  I think the > problem is NOT NULL should come first: iddiary INT NOT NULL > AUTO_INCREMENT. > > 2009/5/28 João Cândido de Souza Neto : >> It´s not auto_increment, it´s auto increment. >> >> -- >> João Cândido de Souza Neto >> SIENS SOLUÃÃES EM GESTÃO DE NEGÃCIOS >> Fone: (0XX41) 3033-3636 - JS >> www.siens.com.br >> >> "Grega Leskovsek" escreveu na mensagem >> news:1df2d4810905280748uec4f425kaf14b6410caa...@mail.gmail.com... >> I GOT THIS ERROR when  I tried first sample with when timestamp; >> >> >> ERROR 1064 (42000): You have an error in your SQL syntax; check the >> manual thatcorresponds to your MySQL server version for the right >> syntax to use near 'id(iddiary) )' at line 1 >> >> >> 2009/5/28 João Cândido de Souza Neto : >>> If you need date and hour the best way is: >>> >>> CREATE TABLE diary ( >>> iddiary int auto_increment not null, >>> imepriimek varchar(50), >>> when timestamp, >>> action varchar(30), >>> onfile varchar(100) >>> unique id(iddiary) >>> ); >> >> Please advice. Thanks in advance, Grega >>> >>> if you need only date you can use: >>> >>> CREATE TABLE diary ( >>> iddiary int auto_increment not null, >>> imepriimek varchar(50), >>> when date, >>> action varchar(30), >>> onfile varchar(100) >>> unique id(iddiary) >>> ); >>> >>> To get formated date you should use: >>> >>> select date_format(when, "%T%W%e%c%y") from diary; >>> >>> To put data in this field you can use: >>> >>> insert into diary (when) values (str_to_date("10:55:14Thursday28509", >>> "%T%W%e%c%y")); >>> >>> >>> >>> -- >>> João Cândido de Souza Neto >>> SIENS SOLUÃÃES EM GESTÃO DE NEGÃCIOS >>> Fone: (0XX41) 3033-3636 - JS >>> www.siens.com.br >>> >>> "Grega Leskovsek" escreveu na mensagem >>> news:1df2d4810905280643y62a0f092p91fa2c57558d8...@mail.gmail.com... >>>> CREATE TABLE diary(iddiary int auto_increment not null, imepriimek >>>> varchar(50), when date("%T%W%e%c%y"), action varchar(30), onfile >>>> varchar(100) unique id(iddiary)); >>>> >>>> I tried the above and it didn't work. What must I do to create a table >>>> with full time and date. If I should use timestamp how do I convert >>>> thee timestamp in php back to "normal" time? (I also tried the mysql >>>> command: >>>> when timestamp >>>> and >>>> when date >>>> in the above first mysql clause but it didnt work >>>> ) >>>> >>>> Please help me. Thanks in advance, >>>> -- >>>> When the sun rises I receive and when it sets I forgive -> >>>> http://users.skavt.net/~gleskovs/ >>>> All the Love, Grega Leskov'sek >>> >>> >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> >> >> >> >> -- >> When the sun rises I receive and when it sets I forgive -> >> http://users.skavt.net/~gleskovs/ >> All the Love, Grega Leskov'sek >> >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- When the sun rises I receive and when it sets I forgive -> http://users.skavt.net/~gleskovs/ All the Love, Grega Leskov'sek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql connections
how do I make a permanent connection to mysql database and what is difference between mysql_connect() and permanent one? If I make connections in one file and redirect it to another file do I keep connection (permanent / standard)? Do I lose connection only when I type mysql_close (permanent/ standard)? if I select different database between the php program do I need to do something extra along mysql_select_db("dbname",$link)? If I opened db in another php file, where do I get the $link variable from = mysql_connect (when selecting another database)? Thanks in advance, -- When the sun rises I receive and when it sets I forgive -> http://users.skavt.net/~gleskovs/ All the Love, Grega Leskov'sek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mail and mysql confirmation of that [double-opt in]
how is the best way to check if email address is valid: is this preg_match() OK? preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/', $email); How can I make double opt-in mail system? My idea: 1.) I remember the email entered and user data and the sha1($email); in mysql db 2.) I send email with activation link of the sha1($email); 3.) I am not clear how to proceed when the link is activated. How to update the db and submit the necessary form to the marketing. Thanks in advance, -- When the sun rises I receive and when it sets I forgive -> http://users.skavt.net/~gleskovs/ All the Love, Grega Leskov'sek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] setting cookie doesn't work
Here is one of my final objectives at PHP introductory course ot O'Reilly. The strange thing that setting a cookie in that program les13uadownload.php doesn't work. I don't have a clue - sometimes in other programs when I run them they set cookies and sometimes not. To see the full functionality of this "program" I had to set cookie sevendays in another program. Please check where is my bug. Thanks in advance, Grega from Slovenia function setcolor(backgcolor,color) { document.getElementById("file").style.color=color; document.getElementById("file").style.background=backgcolor; } function setStyle(x) { document.getElementById(x).style.background="yellow"; } function unSetStyle(x) { document.getElementById(x).style.background="white"; } function isFormValid (formToCheck) { retVal = true; if ( (formToCheck.email.value).search(/^[\w!#$%&\'*+\/=?^`{|}~.-]+@(?:[a-z\d][a-z\d-]*(?:\.[a-z\d][a-z\d-]*)?)+\.(?:[a-z][a-z\d-]+)$/i) == -1 ) { element = document.getElementById ("new1Label"); element.style.color = "red"; element.style.fontWeight = "bold"; retVal = false; retEmVal = false; } else { element = document.getElementById ("new1Label"); element.style.color = "black"; element.style.fontWeight = "normal"; retEmVal = true; } if (formToCheck.downloaded.value=='no') { ret7daysVal = true; }else { ret7daysVal = false; } if (!retEmVal) { alert ("Please enter a valid e-mail address!"); retVal = false; }else if (!ret7daysVal) { alert ("You can download the file only once in seven days!"); retVal = false; } return retVal; } "; if (preg_match("/Macintosh/",$ua)) { if (!preg_match("/Firefox/",$ua)) { echo "For Macintosh You need to use Firefox! http://www.apple.com/downloads/macosx/internet_utilities/mozillafirefox.html\";>Download here ..."; exit(); } } if (preg_match("/Windows/",$ua)) { if (!preg_match("/MSIE/",$ua)) { echo "For Windows You need to use Internet Explorer!"; exit(); } } $ip = $_SERVER['REMOTE_ADDR']; $ipCheck = substr($ip,0,3); if ($ipCheck == "202") {echo "I don't trust You."; exit();} ?> Not my email: ? Enter Your e-mail: "> "/> -- When the sun rises I receive and when it sets I forgive -> http://users.skavt.net/~gleskovs/ All the Love, Grega Leskov'sek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: setting cookie doesn't work
And here is the objective: Alter your Acme, Inc. download interface from the previous lesson(I had to not to allow users on computers straing IP with 202 and allow only IE for Win and FF for Mac to download file) so that each user must register her email address in order to download the file. Use cookies to detect whether the user has already registered, and to ensure that the user downloads the file only once within 7 days of registering. As always, validate the forms, comment your code, and explain your results! 2009/8/3 Grega Leskovsek : > Here is one of my final objectives at PHP introductory course ot > O'Reilly. The strange thing that setting a cookie in that program > les13uadownload.php doesn't work. I don't have a clue - sometimes in > other programs when I run them they set cookies and sometimes not. To > see the full functionality of this "program" I had to set cookie > sevendays in another program. Please check where is my bug. Thanks in > advance, Grega from Slovenia > > if (!empty($_GET['delete_cookie'])) { > setcookie("sevendays", "", time()-3600); //delete the cookie to > allow to download the file more than 1x in 7days as another user > } > > if > (isset($_POST['check'])AND(isset($_POST['email']))AND(empty($_COOKIE["sevendays"]))) > {#user clicked form download button > $email = $_POST['email']; > setcookie("sevendays", "email", time()+60*60*24*7); > $filepath = $_SERVER['DOCUMENT_ROOT']."/.php_files/acme_brochure.pdf"; > if (file_exists($filepath)) { > header("Content-Type: application/force-download"); > header("Content-Disposition:filename=\"brochure.pdf\""); > $fd = fopen($filepath,'rb'); > fpassthru($fd); > fclose($fd); > } > }#isset(check) > ?> > > function setcolor(backgcolor,color) { > document.getElementById("file").style.color=color; > document.getElementById("file").style.background=backgcolor; > } > > function setStyle(x) { > document.getElementById(x).style.background="yellow"; > } > function unSetStyle(x) { > document.getElementById(x).style.background="white"; > } > > function isFormValid (formToCheck) { > retVal = true; > > if ( > (formToCheck.email.value).search(/^[\w!#$%&\'*+\/=?^`{|}~.-]+@(?:[a-z\d][a-z\d-]*(?:\.[a-z\d][a-z\d-]*)?)+\.(?:[a-z][a-z\d-]+)$/i) > == -1 ) > { > element = document.getElementById ("new1Label"); > element.style.color = "red"; > element.style.fontWeight = "bold"; > retVal = false; > retEmVal = false; > } > else > { > element = document.getElementById ("new1Label"); > element.style.color = "black"; > element.style.fontWeight = "normal"; > retEmVal = true; > > } > > if (formToCheck.downloaded.value=='no') { > ret7daysVal = true; > }else { > ret7daysVal = false; > } > > if (!retEmVal) > { > alert ("Please enter a valid e-mail address!"); > retVal = false; > }else if (!ret7daysVal) > { > alert ("You can download the file only once in > seven days!"); > retVal = false; > } > > return retVal; > > } > > require($_SERVER['DOCUMENT_ROOT']."/template_top.inc"); > $ua = $_SERVER['HTTP_USER_AGENT'].""; > if (preg_match("/Macintosh/",$ua)) { > if (!preg_match("/Firefox/",$ua)) { > echo "For Macintosh You need to use Firefox! href=\"http://www.apple.com/downloads/macosx/internet_utilities/mozillafirefox.html\";>Download > here ..."; > exit(); > } > } > if (preg_match("/Windows/",$ua)) { > if (!preg_match("/MSIE/",$ua)) { > echo "For Windows You need to use Internet Explorer!"; > exit(); > } > } > $ip = $_SERVER['REMOTE_ADDR']; > $ipCheck = substr($ip,0,3); > if ($ipCheck == "202") {echo "I don't trust You."; exit();} > ?> > if (!empty($_
[PHP] Re: setting cookie doesn't work
I made two files now of the program: (the main one and the one where I set the cookie and open pdf)and I noticed that it doesn't work setting the cookie the first time I call the file where I set the cookie but only after the second header redirection. How do I refresh the page in php? Thanks in advance, Grega from Slovenia 2009/8/3 Grega Leskovsek : > And here is the objective: > Alter your Acme, Inc. download interface from the previous lesson(I > had to not to allow users on computers straing IP with 202 and allow > only IE for Win and FF for Mac to download file) so that each user > must register her email address in order to download the file. Use > cookies to detect whether the user has already registered, and to > ensure that the user downloads the file only once within 7 days of > registering. > > As always, validate the forms, comment your code, and explain your results! > > > 2009/8/3 Grega Leskovsek : >> Here is one of my final objectives at PHP introductory course ot >> O'Reilly. The strange thing that setting a cookie in that program >> les13uadownload.php doesn't work. I don't have a clue - sometimes in >> other programs when I run them they set cookies and sometimes not. To >> see the full functionality of this "program" I had to set cookie >> sevendays in another program. Please check where is my bug. Thanks in >> advance, Grega from Slovenia >> >> > if (!empty($_GET['delete_cookie'])) { >> setcookie("sevendays", "", time()-3600); //delete the cookie to >> allow to download the file more than 1x in 7days as another user >> } >> >> if >> (isset($_POST['check'])AND(isset($_POST['email']))AND(empty($_COOKIE["sevendays"]))) >> {#user clicked form download button >> $email = $_POST['email']; >> setcookie("sevendays", "email", time()+60*60*24*7); >> $filepath = $_SERVER['DOCUMENT_ROOT']."/.php_files/acme_brochure.pdf"; >> if (file_exists($filepath)) { >> header("Content-Type: application/force-download"); >> header("Content-Disposition:filename=\"brochure.pdf\""); >> $fd = fopen($filepath,'rb'); >> fpassthru($fd); >> fclose($fd); >> } >> }#isset(check) >> ?> >> >> function setcolor(backgcolor,color) { >> document.getElementById("file").style.color=color; >> document.getElementById("file").style.background=backgcolor; >> } >> >> function setStyle(x) { >> document.getElementById(x).style.background="yellow"; >> } >> function unSetStyle(x) { >> document.getElementById(x).style.background="white"; >> } >> >> function isFormValid (formToCheck) { >> retVal = true; >> >> if ( >> (formToCheck.email.value).search(/^[\w!#$%&\'*+\/=?^`{|}~.-]+@(?:[a-z\d][a-z\d-]*(?:\.[a-z\d][a-z\d-]*)?)+\.(?:[a-z][a-z\d-]+)$/i) >> == -1 ) >> { >> element = document.getElementById ("new1Label"); >> element.style.color = "red"; >> element.style.fontWeight = "bold"; >> retVal = false; >> retEmVal = false; >> } >> else >> { >> element = document.getElementById ("new1Label"); >> element.style.color = "black"; >> element.style.fontWeight = "normal"; >> retEmVal = true; >> >> } >> >> if (formToCheck.downloaded.value=='no') { >> ret7daysVal = true; >> }else { >> ret7daysVal = false; >> } >> >> if (!retEmVal) >> { >> alert ("Please enter a valid e-mail address!"); >> retVal = false; >> }else if (!ret7daysVal) >> { >> alert ("You can download the file only once in >> seven days!"); >> retVal = false; >> } >> >> return retVal; >> >> } >> >> //You dont need this line> > require($_SERVER['DOCUMENT_ROOT']."/template_top.inc&quo