Dynadot โ€” .com Registration $8.99

Form push button to remove info from db

Spaceship Spaceship
Watch

Rudy

Established Member
Impact
16
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.

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
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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:
PHP:
$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 :)
 
0
•••
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 ;)
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back