NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page form push button to remove info from db

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 03-18-2006, 07:37 PM THREAD STARTER               #1 (permalink)
NamePros Regular
 
Rudy's Avatar
Join Date: Jul 2005
Location: United States
Posts: 586
Rudy is just really niceRudy is just really niceRudy is just really niceRudy is just really nice
 


Save a Life

form push button to remove info from db


Hey everyone. I am building a form right now that has 1 input field - email address.

Basically, the form will allow users to add their email addresses into a database, so that they can receive electronic newsletters.

What I want to do is include a 2nd button beside the "submit" button that will alow a user to remove his or her email address from the db as well.

I figure that using a "push button" is the way I need to go, and that I need to create some function that will get the email address in the email address input field, and "post" that by refreshing the page which will activate my PHP script that will recognize the email address is to be removed from the database, and which will do it.
????: NamePros.com http://www.namepros.com/programming/178203-form-push-button-remove-info-db.html

That's what I think needs to happen. Any idea on how this is actually done??

Here's what I'm thinking what to do in my html:
Code:
<input type="button" value="Remove Your Address" ONCLICK="window.location.href='newsletter.php?remove'">
Notice I put the ?remove at the end of the url. Would this work, to give the value "remove" to my php script? If I did it like this, how would I also get the email address to be recognized?

Thanks,
David
__________________
Smooth Stone Services
Affordable Web Hosting Solutions Starting at only $4.95/month, IT Consulting and Technical Support


Hunt Sources - Hunting Resources Online
Rudy is offline  
Old 03-20-2006, 06:48 PM   #2 (permalink)
New Member
Join Date: Mar 2006
Posts: 5
recycled is an unknown quantity at this point
 



I'm not sure if that would work but you can try it.

I've used this method before and I think it might work for you too:

In your form:
Code:
<form action="newsletter.php">
<input type="submit" name="newsletter" value="Add Your Address">
<input type="submit" name="newsletter" value="Remove Your Address">
Then in your php code do a check:
????: NamePros.com http://www.namepros.com/showthread.php?t=178203
PHP Code:
$newsletter=$_POST['newsletter']
if(
$newsletter=='Remove Your Address'){
  
// code to remove e-mail address
}
if(
$newsletter=='Add Your Address'){
  
// code to add e-mail address

Give it a try and good luck
recycled is offline  
Old 03-22-2006, 06:01 PM   #3 (permalink)
NamePros Member
 
Mall23's Avatar
Join Date: Oct 2005
Posts: 27
Mall23 is an unknown quantity at this point
 



you can also do

Code:
<input type='button' value='Remove Your Address' ONCLICK="window.location.href='newsletter.php?remove=T&sEmail='+document.formname.fieldname.value;">
or you could get all wiz-bang and use some AJAX like I did on www.fun2pic.com when you submit the form.

neeto! yey! whohoo! *backflips*


...you can copy the code (not like I can stop you, nor do you have my permission -- or ANY of you dingdongs!) on the client side, but not the server side...nah nah nah
Mall23 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Transforming a Form button into Normal button dima777 Website Development 4 11-08-2005 10:40 PM
NEW : Google AdSense(TM) Online Standard Terms and Conditions Mark Google Adsense 3 11-04-2005 01:37 PM
$75 Contest For HTML Layout Compelling FORM btrader Design Contests 17 09-10-2005 08:01 AM
changing button colors in form lovelylovely Web Design Discussion 6 05-15-2005 11:37 AM
php contact form wioth submit button TWM Programming 2 11-11-2003 11:20 AM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 08:04 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger