hypnoticvibe Posted November 6, 2006 Share Posted November 6, 2006 I am PHP illiterate. I tried to write a little subscription form like this:[code]<?php$address = $_POST['email'];if ($address) { $to = "[email protected]"; $subject = "Subscribe Me"; $body = "This is a request to add someone to the mailing list."; mail($to, $subject, $body, "From: " . $address . "\r\nX-Mailer: Subscription Script\r\n"); echo "You have been subscribed.";}else { echo "Unsuccessful. Please try again.";}?>[/code]Here is the mark-up that corresponds:[code]<form method="post" action="subscribe.php"> <label for="email"><strong>E-Mail:</strong></label><input id="email" type="text" size="30" name="email" tabindex="1" /><input type="submit" value="Subscribe" tabindex="2" /></form>[/code]What happens is that the person's "name" is always:[quote]Your name[/quote]Unfortuntely, replaying and called people "Your name" tends to confuse people, ;) Link to comment https://forums.phpfreaks.com/topic/26343-super-simple-mail-subscription-thing/ Share on other sites More sharing options...
Orio Posted November 6, 2006 Share Posted November 6, 2006 I dont see where the user needs to enter his name name nor how you send/store it.Orio. Link to comment https://forums.phpfreaks.com/topic/26343-super-simple-mail-subscription-thing/#findComment-120435 Share on other sites More sharing options...
hypnoticvibe Posted November 6, 2006 Author Share Posted November 6, 2006 Grrrrrrr. My mind is scattered these days. Sorry for confusion. I figured out how to make the subscription form by referencing the E-Mail form a friend wrote for me so I mixed the 2 up. Here's the E-Mail form that's having the problem I described:[code][<?php /* * SPRONKware E-mail Form Handler * * (c)2006 Keith Humm - SPRONKware * * This script may be used, unmodified or modified, with recognition in the form of: * "This script originally written by Keith Humm - SPRONKware / firestudio. * www.spronkware.com, www.firestudio.co.nz" at the top of the comments. */ /* * Import (required - break if it doesn't exist) the SPRONKware Form Validation Library * which includes sw_botCheck() and sw_validateEmailAddress(). */ require('sw_formvalid_v1.0.php'); /* * Sends an e-mail formatted to the correct array specification: * ['to']: valid e-mail address to send e-mail to * ['subject']: Subject text of e-mail * ['contents']: Message contents, can contain HTML. * ['headers']: Additional headers as defined in email RFC. Should include 'From: Name <[email protected]>' at minimum. */ function sendEmail($tfsc_array) { mail( $tfsc_array['to'], $tfsc_array['subject'], $tfsc_array['contents'], $tfsc_array['headers'] ); } /* * SCRIPT BODY * * - Checks fields are filled out and of acceptable size. * - Runs Spam Bot Check * - Checks for e-mail address validity * - Sends e-mail * - (COMMENTED OUT) Sends automatic reply. */ // Check fields are filled out if(!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['message'])) { echo("<h1>Error</h1><p>Please fill out all fields. Press the back button to go back.</p>"); } // Check name and e-mail for acceptable size. if(strlen($_POST['name']) > 255 || strlen($_POST['email'] > 255)) { echo("<h1>Error</h1><p>You have exceeded the maximum length for a name or e-mail address. Press the back button to go back.</p>"); } // Validate user and user agent with botCheck from FormValid library. sw_botCheck(); // Validate E-mail Address if(sw_validateEmailAddress($_POST['email'])) { // Validation passed, format e-mail array $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $userEmail['to'] = "[email protected]"; $userEmail['headers'] = "From: Your Name <".$email.">"; $userEmail['subject'] = "E-mail form submission from ".$name." <".$email.">"; $userEmail['contents'] = html_entity_decode($message); // Send e-mail. sendEmail($userEmail); // Now redirect user to thanks page. header( "Location: thanks.php" ); } else { // E-mail address not valid. echo("<h1>Error</h1><p>We have detected that the e-mail address entered is invalid. Please press back and check this, otherwise send e-mail using the address noted on the <a href=\"contact.html\">contact details</a> page."); }?>[/code] Link to comment https://forums.phpfreaks.com/topic/26343-super-simple-mail-subscription-thing/#findComment-120583 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.