Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP mailer Radio button issue
Old 04-22-2010, 04:52 PM PHP mailer Radio button issue
Junior Talker

Posts: 1
Name: Tiger
Trades: 0
Hello there experts
Can anybody help me with a simple solution to my problem? I have a form that works fine, I do receive the email with the information filled in the online form but not the info about:
>> which of the 2 radio button has been checked<<. Yes I just started with php so apologies if the solution is obvious and thaks in advance.
Script:
PHP Code:
<?php
try {
    if (empty(
$_POST)) {
        throw new 
Exception('Invalid entry point', - 1);
    }
    
$requiredPostVars = array('name' 'email' 'message');
    
$form = array();
    
    
//Mandatory fields check
    
foreach ($requiredPostVars as $field) {
        if (! isset(
$_POST[$field])) {
            throw new 
Exception('Mandatory field missing: ' $field, - 2);
        }
        
$form[$field] = stripslashes(trim($_POST[$field]));
        if (empty(
$form[$field])) {
            throw new 
Exception('Mandatory field empty: ' $field, - 3);
        }
    }
    
//E-mail address validation        
    
if(!preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/"$form['email'])) {
        throw new 
Exception('Invalid e-mail address: ' $form['email'], - 4);
    }
        
    include_once 
'class.phpmailer.php';    
        
    
$body '<b>Naam</b>: ' $form['name'] . '<br/><br/>' .
            
'<b>E-mail</b>: ' $form['email'] . '<br/><br/>' .
           
'<b>Bericht gaat over</b>: ' $form['value'] . '<br/><br/>' .
            
'<b>Vraag of opmerking</b>: ' nl2br($form['message']);
        
    
// Send Mail
    
$mail = new PHPMailer();
    
$mail->From "[EMAIL="info@blabla.nl"]info@blabla.nl[/EMAIL]";
    
$mail->FromName $mail->From;
    
$mail->Subject "E-mail vanaf contactformulier [URL="http://www.blabla.nl"]www.blabla.nl[/URL]";
    
    
$mail->AltBody strip_tags(str_replace('<br/>'PHP_EOL$body));
  
$mail->Body $body;
    
$mail->AddAddress([EMAIL="info@blabla.nl"]info@blabla.nl[/EMAIL]);
    
    if (! 
$mail->Send()) {
        throw new 
Exception("Mailer Error: " $mail->ErrorInfo, -5);
    }
    
    
// E-mail sent correctly
    
include_once 'bedankt.html';
    
} catch (
Exception $e) {
    
    
// There was a problem with the input parameters or on sending the e-mail
    
include_once 'error.html';
}

Last edited by chrishirst; 04-23-2010 at 06:33 PM..
Webill is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-26-2010, 04:47 AM Re: PHP mailer Radio button issue
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Wouldn't hurt much to provide the HTML for your form.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 04-26-2010, 09:11 AM Re: PHP mailer Radio button issue
Average Talker

Posts: 22
Trades: 0
Tested, it works with all the fields. changes are commented with "##########"
########## This part ################
HTML Code:
 <form action="test10.php" method="post">
  Message<input type="text" name="message">
  Value<input type="text" name="value">
  Name <input type="text" name="name">
  Email <input type="text" name="email">
  Save <input type="Submit" value="Save">
  </form>
############ This part #################
PHP Code:
  <?php
     
try {     
      if(empty(
$_POST)){
        throw new 
Exception('Invalid entry point', - 1);
      }
   
      
##### Added the value here ##################
      
$requiredPostVars = array('name' 'email' 'message','value');
      
$form = array();
      
      
//Mandatory fields check
       
foreach($requiredPostVars as $field){
   
          if (!isset(
$_POST[$field])) {
              throw new 
Exception('Mandatory field missing: ' $field, - 2);
          }
   
          
$form[$field] = stripslashes(trim($_POST[$field]));
   
          if (empty(
$form[$field])) {
             throw new 
Exception('Mandatory field empty: '.$field, - 3);
          }
      }
      
//E-mail address validation        
      
if(!preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/"$form['email'])) {
          throw new 
Exception('Invalid e-mail address: ' $form['email'], - 4);
      }
   
   
          
      include_once 
'phpmailer/class.phpmailer.php';    
          
      
$body '<b>Naam</b>: ' $form['name'] . '<br/><br/>' .
              
'<b>E-mail</b>: ' $form['email'] . '<br/><br/>' .
             
'<b>Bericht gaat over</b>: ' $form['value'] . '<br/><br/>' .
              
'<b>Vraag of opmerking</b>: ' nl2br($form['message']);
          
      
// Send Mail
      
$mail = new PHPMailer();
      
      
############### If IsSMTP then to use host , user and password methods - which I hope you know already###################              
      
$mail->IsMail();
   
      
$mail->From "lovein@blaksmail.com";
      
$mail->FromName $mail->From;
      
$mail->Subject "E-mail vanaf contactformulier";
      
      
$mail->AltBody strip_tags(str_replace('<br/>'PHP_EOL$body));
      
$mail->Body $body;
      
$mail->AddAddress("prakash@sourcebits.com");
      
      if (!
$mail->Send()) {
         throw new 
Exception("Mailer Error: " $mail->ErrorInfo, -5);
      }
      
      
// E-mail sent correctly
      
include_once 'bedankt.html';
      
  } catch (
Exception $e) {
      
      
// There was a problem with the input parameters or on sending the e-mail
      
include_once 'error.html';
  } 
  
?>
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by chrishirst; 04-26-2010 at 10:19 AM.. Reason: added code tags
katierosy is offline
Reply With Quote
View Public Profile Visit katierosy's homepage!
 
Old 04-26-2010, 11:53 PM Re: PHP mailer Radio button issue
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Not to be too facetious, but your radio buttons might not work b/c they don't exist. Of course, you could have just accidentally posted everything except the radio button code.

Edit: Oops. Didn't see that the last post wasn't from the OP, lol.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 04-27-2010, 10:05 AM Re: PHP mailer Radio button issue
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 680
Name: Lashtal
Trades: 0
Quote:
Originally Posted by JeremyMiller View Post
...your radio buttons might not work b/c they don't exist...
that was my initial thought as well.
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP mailer Radio button issue
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22687 seconds with 12 queries