[PHP] Newbie form question
Hello. I have an application that generete HTML5 form in PHP. The form is written in a while loop and therefore the form field has exact same name for every row in the loop. And that is the problem. Because when my PHP document shall handle submitted data it only take the very last row in the while loop and show the result of it. if(isset($_POST['update_explosive'])){ $item_serial_number = $_POST['item_serial_number']; $update_item_in_store = $_POST['update_item_in_store']; if($item_serial_number === ETX1.22X1000){ echo h1$update_item_in_store/h1; } if($item_serial_number === ETX1.17X460){ echo h1$update_item_in_store/h1; } } I think the solution will be to create different and unike fieldname dymamic. For example I tried to write input type=text name=?php echo $item_serial_number; ? value=?php echo $item_serial_number; ? in the HTML5/PHP form. But the problem is that periode . not is allowed as $variable_name. I then try to write it this way: if(isset($_POST['update_explosive'])){ $item_serial_number = $_POST['ETX1.22X1000']; $update_item_in_store = $_POST['update_item_in_store']; if($item_serial_number === ETX1.22X1000){ echo h1$update_item_in_store/h1; } if($item_serial_number === ETX1.17X460){ echo h1$update_item_in_store/h1; } } But this last part did not make any sense to me. I recive no output when tried that one. One problem is that I have between 2 and 25 items with different serial number. Sometimes only 5 of this shall be updated and other times all 25 items. I like to do this through one simple form and not for one time for every single item. (I know how to do when select one by one and update them, but that is a long and hard way for people using my application. A better solution is to just use one form and view all items there. Then just write the amount of item in input type=number name=update_item_in_store size=6 field.) If you have time to help me *understand* this newbie question by explain or give me an example or post a link to a tutorial that can help me though, I am very thankful. Karl
Re: [PHP] Newbie Form Question
Richard Lynch wrote: ?php if (isset($_REQUEST['email'])){ $success = mail($_REQUEST['action'], 'un/subscribe', 'un/subscribe', From: $_REQUEST[email]\r\nReply-to: $_REQUEST[email]); if ($success) echo Status Change Sent; else echo Unable to send Status Change; } ? What if someone submitted: action = [EMAIL PROTECTED] email = [EMAIL PROTECTED] long winded evil spam message here ? -- David Dorward http://blog.dorward.me.uk/ http://dorward.me.uk/ Home is where the ~/.bashrc is -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Form Question
On Mon, August 7, 2006 2:37 am, David Dorward wrote: Richard Lynch wrote: ?php switch($_REQUEST['email']){ case '[EMAIL PROTECTED]': case '[EMAIL PROTECTED]': //Do nothing. break; default: die(Hack attempt.); break; } if (isset($_REQUEST['email'])){ $success = mail($_REQUEST['action'], 'un/subscribe', 'un/subscribe', From: $_REQUEST[email]\r\nReply-to: $_REQUEST[email]); if ($success) echo Status Change Sent; else echo Unable to send Status Change; } ? What if someone submitted: action = [EMAIL PROTECTED] email = [EMAIL PROTECTED] long winded evil spam message here ? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Form Question
Better yet, don't allow the user to enter a From address. Simply give them subscribe and unsubscribe radio buttons, and make sure the un/subscribe-ee gets a confirmation email. And certainly check your input fields for newlines. :) On 8/7/06, Richard Lynch [EMAIL PROTECTED] wrote: On Mon, August 7, 2006 2:37 am, David Dorward wrote: Richard Lynch wrote: ?php switch($_REQUEST['email']){ case '[EMAIL PROTECTED]': case '[EMAIL PROTECTED]': //Do nothing. break; default: die(Hack attempt.); break; } if (isset($_REQUEST['email'])){ $success = mail($_REQUEST['action'], 'un/subscribe', 'un/subscribe', From: $_REQUEST[email]\r\nReply-to: $_REQUEST[email]); if ($success) echo Status Change Sent; else echo Unable to send Status Change; } ? What if someone submitted: action = [EMAIL PROTECTED] email = [EMAIL PROTECTED] long winded evil spam message here ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Newbie Form Question
I was wondering how simple it would be to set up a script to provide a subscribe/unsubscribe form for a list serve. The form would send an email to the subscribe address or unsubscribe address as selected. Thanks David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Newbie Form Question
[snip] I was wondering how simple it would be to set up a script to provide a subscribe/unsubscribe form for a list serve. The form would send an email to the subscribe address or unsubscribe address as selected. [/snip] I wondered about that the other day myself and came to the conclusion that it would be really simple. It must be, others have done it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Form Question
On Friday 04 August 2006 13:27, Jay Blanchard wrote: [snip] I was wondering how simple it would be to set up a script to provide a subscribe/unsubscribe form for a list serve. The form would send an email to the subscribe address or unsubscribe address as selected. [/snip] I wondered about that the other day myself and came to the conclusion that it would be really simple. It must be, others have done it. Not terribly difficult at all. One SMTP library for PHP and you're away. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Form Question
In most cases, your PHP build is set up with mail() attached to whatever SMTP you have on the server. you would just use the following... mail($recipientemail,$subject,$message); On 8/4/06, Duncan Hill [EMAIL PROTECTED] wrote: On Friday 04 August 2006 13:27, Jay Blanchard wrote: [snip] I was wondering how simple it would be to set up a script to provide a subscribe/unsubscribe form for a list serve. The form would send an email to the subscribe address or unsubscribe address as selected. [/snip] I wondered about that the other day myself and came to the conclusion that it would be really simple. It must be, others have done it. Not terribly difficult at all. One SMTP library for PHP and you're away. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Form Question
Yes, the list serve software has the opt-in/confirmation stuff covered. I'm just trying to get the sub/unsub form on the website going. Thanks David On 8/4/06 8:40 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: are you doing your own mailing list management, or using a package that includes an explicit subscribe/unsubscribe confirmation capability? if you're doing your own list management, then you need to design an explicit opt-in/-out system. i.e., no e-mail address is added to (or removed from) the list until the user has responded to a specific/unique/non-guessable confirmation bit that is included in the confirming message that is sent to them (or some other form of explicit confirmation). doing this isn't that hard, but far more than a simple form. if you're using an existing mailing list management package (that includes opt-in/-out confirmation capabilities) and you're simply feeding the initial subscribe/unsubscribe request to that facility, then this is probably fairly easy. [it is unwise (and if this is in the US context, be aware of the requirements of the can-spam law) to set up a mailing list that does not include opt-in/-out confirmation requirements.] - Rick Original Message Date: Friday, August 04, 2006 08:14:58 AM -0400 From: David Ellsworth [EMAIL PROTECTED] To: php-general@lists.php.net Subject: [PHP] Newbie Form Question I was wondering how simple it would be to set up a script to provide a subscribe/unsubscribe form for a list serve. The form would send an email to the subscribe address or unsubscribe address as selected. Thanks David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Form Question
what I need is what I would use after the form is submitted - responding to whether the form sent the value (post likely from a dropdown field) of subscribe or unsubscribe to the posted page for processing. On 8/4/06 8:52 AM, Duncan Hill [EMAIL PROTECTED] wrote: On Friday 04 August 2006 13:27, Jay Blanchard wrote: [snip] I was wondering how simple it would be to set up a script to provide a subscribe/unsubscribe form for a list serve. The form would send an email to the subscribe address or unsubscribe address as selected. [/snip] I wondered about that the other day myself and came to the conclusion that it would be really simple. It must be, others have done it. Not terribly difficult at all. One SMTP library for PHP and you're away. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Form Question
On Fri, August 4, 2006 7:14 am, David Ellsworth wrote: I was wondering how simple it would be to set up a script to provide a subscribe/unsubscribe form for a list serve. The form would send an email to the subscribe address or unsubscribe address as selected. It's pretty simple: ?php if (isset($_REQUEST['email'])){ $success = mail($_REQUEST['action'], 'un/subscribe', 'un/subscribe', From: $_REQUEST[email]\r\nReply-to: $_REQUEST[email]); if ($success) echo Status Change Sent; else echo Unable to send Status Change; } ? form action=?php echo $_SERVER['PHP_SELF']? method=post input type=radio name=action value=[EMAIL PROTECTED] Subscribe input type=radio name=action value=[EMAIL PROTECTED] Unsubscribebr / input name=email /form -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php