28, May 2012

checkboxes and $_POST, send HTML mail - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: checkboxes and $_POST, send HTML mail
« previous next »
Pages: [1] Print

Author Topic: checkboxes and $_POST, send HTML mail  (Read 1854 times)
Chicken-run Manager
*
Gender: Male
Posts: 9
62 credits
Members referred : 0



« on: Aug 28, 2006, 05:39:18 am »

Hello all, Olaf !
Been hacking away on the user_access class and extended it to suit my specific needs, some changes and some improvements that suited my taste ! Very nice that this oo c++ style feature is now a part of php, makes it quiet useful !!
My question is trivial (i am sure) as usual. How do I check a checkbox after reading the db and finding a value "true" or "1" ? As opposed to "" or false if you will ??
<input type=CHECKBOX name="architect" value="1" /> is y box , simple as it was , and my input fields are
<TD width="414"><INPUT TYPE="text" NAME="name" SIZE="30" value="<?php echo
(isset($_POST['name'])) ? $_POST['name'] : "" ?>"></TD> ,  working quiet well of course !!
Anyone real good at the php/html html/php mixing when it comes to the checkbox scenario above ??
Secondly, sending HTML mail, are there templates one can use to avoid a lot of HTML typing for the body, hate html...sorry..just can't wrap my small swedish brain around it late at night...(yepp I am planning to write yet another function to your class Olaf  Cool  ) Want to avoid extensive (in my case) typos and html tag consfusion !!??

Thanks a lot  Smiley
Salut
Anders
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Aug 28, 2006, 08:29:35 am »

Hi Anders,

You understand that I don't answer the post at phpclasses dot org...Wink
About the checkbox, the problem is that the check doesn't exists in the POST array if not checked, I solve this most of the time like this:
Code:
$var = (!empty($_POST['checkbox'])) ? $_POST['checkbox'] : "default value";

About the html mail, you're right the current mails are not so fine, I have almost finished the html version of my mailer class and I will use this class inside access_user in future version's. I wrote already in my own project a version where all mail's are written via mail templates. I will add this as important future update to the development list.

Chicken-run Manager
*
Gender: Male
Posts: 9
62 credits
Members referred : 0



« Reply #2 on: Aug 28, 2006, 09:13:09 am »

Ahaa !! I knew I had missed some important part of the story ! Thank you, most helpful indeed ! I took a shot at it through a if ($new_user->mycheckboxvalue == 1) etc etc and then depending on whether the logic produced true or false I would do a checkbox checked html tag...messy it did not look good and then the whole page kind'a got skewd ...he he..sorry ! So, to see if you smart guys and gals had a smoother solution I asked ! Yes, I am on the clear now that phpclasses is not where one can find your excellent supportive comments...I think I know why.. ! I am impressed with the breath of your knowledge and your persistent support !! I think I will take a shot at the html....but had to ask, lazy as I am...terrible, yes I know.... Huh
thank you Olaf !! Smiley
Salut
Anders
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Aug 28, 2006, 09:44:42 am »

you're welcome...

Chicken-run Manager
*
Gender: Male
Posts: 9
62 credits
Members referred : 0



« Reply #4 on: Aug 28, 2006, 11:19:06 pm »

Worked beatuifully ! Excellent ! I also added a function in ext_user_profile.php to display the checkboxes on update_user_profile.php that I collect on my input form. Basically just build the html string and add the checked key word or not. However, there is a small problem doing this. If the update_user_profile.php page receives a check box "checked", all is well, but if I uncheck a checkbox, do a "Save (profile)" the $_POST breaks with the message "Notice: Undefined index: mycheckboxname in /home/server21/www/a-website/update_user_profile.php on line 17. Think I need to print the html string I built for the checkbox, something is going on there that is not ok.....by the way, this html build stuff is going to work well with my email later on since I am asked to send the admin an email with user info on registration....hey this will be pretty cool !
mvh
Anders
Chicken-run Manager
*
Gender: Male
Posts: 9
62 credits
Members referred : 0



« Reply #5 on: Aug 28, 2006, 11:22:09 pm »

Hold on a second..you mentioned that if the checkbox is "un"-checked, there is nothing in the $_POST string stored......nothing meaning what Huh it is deleted...hmmm..looks like it since it is complaining of no or an undefined index...well, I guess I should read the manual....lazy as I am.... Smiley
Chicken-run Manager
*
Gender: Male
Posts: 9
62 credits
Members referred : 0



« Reply #6 on: Aug 29, 2006, 07:33:48 am »

Well, I finally got around the annoying $_POST error in update_user_profile.php. In short and I am sure I have done something really ugly here (as I said need to read the bloody manual once and for all..), the checkboxes do not render anything, zilt when not checked, so the subsequent save_user_date() broke when I unchecked any of my boxes on the update page. I wrote a small function that checked for anyting in the $_POST['mycheckboxvar'] and if nothing there I gave it a default value to go and do the UPDATE with i.e mycheckboxval='whatever', instead of a checked value mycheckboxval='checked'. I tried to make the call right inside the save_user_date(), but was not too successful. So, that was that in short, wrote an additional function to build the checkboxes onthe page, similar to the form thing you wrote Olaf, now I can use this entire page now for a pretty nifty HTML mail Smiley . Well at anyrate, thought I mention this little checkbox thingi here, I am sure there is an elegant way to solve this....than what I did...as I said..where's that manual now...grrr...this $_POST $_GET $_REQUEST etc, takes a bit of time to get used to....my head is coming off....need to hit the hay...it is late here in California....later all !
Anders
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #7 on: Aug 29, 2006, 09:30:55 am »

maybe you like this class too, its possible to validate text fields and and also radio's and checkboxes:


Chicken-run Manager
*
Gender: Male
Posts: 9
62 credits
Members referred : 0



« Reply #8 on: Aug 30, 2006, 08:33:02 am »

I will go and look Olaf thanks !! I am getting the php bug..... Smiley
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #9 on: Aug 30, 2006, 08:44:47 am »

I will go and look Olaf thanks !! I am getting the php bug..... Smiley
php bugs have to be reported here: http://bugs.php.net/

hehe

Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=3855
Tags : php html email Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: checkboxes and $_POST, send HTML mail
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 03:30:30 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.