Current location: Hot Scripts Forums » Programming Languages » PHP » BRAIN BUSTER... Why won't my PHP contact form work on a Yahoo server?


BRAIN BUSTER... Why won't my PHP contact form work on a Yahoo server?

Reply
  #1 (permalink)  
Old 09-03-09, 04:31 PM
thinktec thinktec is offline
Newbie Coder
 
Join Date: Sep 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
BRAIN BUSTER... Why won't my PHP contact form work on a Yahoo server?

This PHP form I'm using on this page is not working (it's on a Yahoo server)...

Turn of the Decade Masquerade Ball

When I put that same form on my personal server (which is hosted with gate.com) it works just fine and I receive the confirmation email and everything.

Can anyone tell me what's going on here? I read in Yahoo's documentation that they require all outgoing emails with PHP to be sent from an email address within your domain BUT I already have that setup.

I'm stumped...

Also, I've tried several other PHP forms I've made (one of them using a combination of Flash and PHP) and not a single one of them will work on this Yahoo hosting server but they ALL work on my gate.com server.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 09-03-09, 05:07 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Please post your code.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 09-03-09, 06:14 PM
thinktec thinktec is offline
Newbie Coder
 
Join Date: Sep 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Sorry about that, here is the code...

This is the code for the contact-form.php script that processes the contact form...

PHP Code:

<div class="contact_form">



<!-- ***** Config ********************************************************** -->

<?php

$contact_form_msg_clear    
'Clear';
$contact_form_msg_submit   'Submit';
$contact_form_msg_submit   $contact_form_graph '' $contact_form_msg_submit;

$contact_form_msg_sent     'Thank you for the RSVP.';
$contact_form_msg_not_sent 'Message not sent. Please try again.';
$contact_form_msg_invalid  'Please, correct the fields marked in red';

?>


<!-- ***** PHP ************************************************************* -->

<?php

// ***** contact_form_mail *****

function contact_form_mail($to$subject$message$headers ''$charset 'utf-8'$files = array())
{
  if (!
count($files))
  {
    
$ext_headers  $headers;
    
$ext_headers .= "Content-Type: text/plain; charset=\"$charset\"\r\n";
    
$ext_message  $message;
  }
  else
  {
    
$boundary 'a6cd792e';
    while (
true)
    {
      if (
strpos($subject$boundary) !== false ||
          
strpos($message$boundary) !== false) { $boundary .= dechex(rand(015)) . dechex(rand(015)); continue; }
      foreach (
$files as $fi_name => $fi_data)
      if (
strpos($fi_name$boundary) !== false ||
          
strpos($fi_data$boundary) !== false) { $boundary .= dechex(rand(015)) . dechex(rand(015)); continue; }
      break;
    }

      
$ext_headers  $headers;
      
$ext_headers .= "MIME-Version: 1.0\r\n";
      
$ext_headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n";

      
$ext_message  "This is a multi-part message in MIME format.";
      
$ext_message .= "\r\n--$boundary\r\n";

      
$ext_message .= "Content-Type: text/plain; charset=\"$charset\"\r\n\r\n";
      
$ext_message .= $message;
      
$ext_message .= "\r\n--$boundary\r\n";

    foreach (
$files as $i => $x)
    {
      
$ext_message .= "Content-Type: {$x['type']}; name=\"{$x['name']}\"\r\n";
      
$ext_message .= "Content-Disposition: attachment\r\n";
      
$ext_message .= "Content-Transfer-Encoding: base64\r\n\r\n";
      
$ext_message .= chunk_split(base64_encode($x['data']));
      
$ext_message .= "\r\n--$boundary\r\n";
    }
  }

  
$error_reportings error_reporting(E_ERROR E_PARSE);
  
$res mail($to$subject$ext_message$ext_headers);
  
$error_reportings error_reporting($error_reportings);

  return 
$res;
}

// ***** contact_form_post *****

function contact_form_post($name)
{
  if (isset(
$_POST[$name])) return htmlentities($_POST[$name], ENT_COMPAT);
  if (isset(
$_GET [$name])) return htmlentities($_GET [$name], ENT_COMPAT);
  return 
'';
}

// ***** Send Mail *****

if (count($_POST))
{
  if (
get_magic_quotes_gpc() && !function_exists('strip_slashes_deep'))
  {
    function 
strip_slashes_deep($value)
    {
      if (
is_array($value)) return array_map('strip_slashes_deep'$value);
      return 
stripslashes($value);
    }

    
$_GET    strip_slashes_deep($_GET);
    
$_POST   strip_slashes_deep($_POST);
    
$_COOKIE strip_slashes_deep($_COOKIE);
  }

  
$patern_aux1 "(\\w+(-\\w+)*)";
  
$patern_aux2 "($patern_aux1\\.)*$patern_aux1@($patern_aux1\\.)+$patern_aux1";

  
$ename '';
  
$email '';
  
$esubj 'RSVP Confirmation Email';
  
$ehead $contact_form_message_prefix;
  
$ebody '';
  
$valid true;
  foreach (
$contact_form_fields as $i => $x)
  {
    
$_POST[$i] = isset($_POST[$i]) ? $_POST[$i] : '';

    if (
$x['type'] === 'upload')
    {
      if (isset(
$_POST["$i-clear"]) && $_POST["$i-clear"])
          unset(
$_SESSION['contact-form-upload'][$i]);
      if (isset(
$_FILES[$i])             &&
                
$_FILES[$i][    'type']  &&
                
$_FILES[$i][    'name']  &&
                
$_FILES[$i]['tmp_name']  &&
    
file_exists($_FILES[$i]['tmp_name']) &&
       
filesize($_FILES[$i]['tmp_name']) <= $x['maxsize'])
                
$_SESSION['contact-form-upload'][$i] =
                    array(
'type' =>                   $_FILES[$i][    'type'],
                          
'name' =>                   $_FILES[$i][    'name'],
                          
'data' => file_get_contents($_FILES[$i]['tmp_name']));
    }

    if (
$x['type'] === 'checkbox'   && trim($_POST[$i]) ||
        
$x['type'] === 'department' && trim($_POST[$i]) ||
        
$x['type'] === 'input'      && trim($_POST[$i]) ||
        
$x['type'] === 'name'       && trim($_POST[$i]) ||
        
$x['type'] === 'select'     && trim($_POST[$i]) ||
        
$x['type'] === 'subject'    && trim($_POST[$i]) ||
        
$x['type'] === 'textarea'   && trim($_POST[$i]) ||
        
$x['type'] === 'email'      && preg_match("/^$patern_aux2$/sDX"$_POST[$i]) ||
        
$x['type'] === 'turing'     && isset($_SESSION['contact-form-number']) && $_POST[$i] === $_SESSION['contact-form-number'] ||
        
$x['type'] === 'upload'     && isset($_SESSION['contact-form-upload'][$i]))
    {
      if ( 
$x['type'] === 'textarea')
           
$ebody .=             "\r\n" $_POST[$i] . "\r\n";

      if ( 
$x['type'] !== 'textarea')
      if (!
$x['name'] && isset($x['prompt']))
           
$ehead .= $x['prompt'] . ' ' $_POST[$i] . "\r\n";
      else 
$ehead .= $x['name'  ] . ' ' $_POST[$i] . "\r\n";
    }
    elseif (
$x['require'] || $_POST[$i] !== '')
    {
      
$valid false;
      if (!
$x['name'] && isset($x['prompt']))
           
$contact_form_fields[$i]['prompt'] = "<em>{$x['prompt']}</em>";
      else 
$contact_form_fields[$i]['name'  ] = "<em>{$x['name'  ]}</em>";
    }

    switch (
$x['type'])
    {
      case 
'department': foreach ($x['items'] as $j => $y) if ($y === $_POST[$i]) $contact_form_email $j; break;
      case 
'email':      $email $_POST[$i]; break;
      case 
'name':       $ename $_POST[$i]; break;
      case 
'subject':    $esubj $_POST[$i]; break;
    }
  }

  if (
$valid)
  {
    
$mail_sent contact_form_mail($contact_form_email$esubj$ehead $ebody,
                                   
"To: $contact_form_email\r\nFrom: $ename <$email>\r\n"$contact_form_encoding,
                                    isset(
$_SESSION['contact-form-upload']) ? $_SESSION['contact-form-upload'] : array());

    if (
$mail_sent)
         echo 
'<div class="error"><em>'               $contact_form_msg_sent     '</em></div>';
    else echo 
'<div class="error"><em class="error">' $contact_form_msg_not_sent '</em></div>';
    if (
$mail_sent$_POST    = array();
    if (
$mail_sent$_SESSION = array();
  }
  else   echo 
'<div class="error"><em>'               $contact_form_msg_invalid  '</em></div>';
}

$_SESSION['contact-form-number'] = str_pad(rand(09999), 4'0'STR_PAD_LEFT);

?>


<!-- ***** HTML ************************************************************ -->

<form method="post" action="<?=$_SERVER['REQUEST_URI'];?>" enctype="multipart/form-data">
<table cellpadding="6">
<?php

$slash 
$contact_form_xhtml '/' '';
foreach (
$contact_form_fields as $i => $x)
{
  
?>
  <tr>
  <th align="right"><?=$x['name'];?></th>
  <td>
  <?php
  
switch ($x['type'])
  {
    case 
'name':
    case 
'email':
    case 
'input':
    case 
'subject':
      
?>
      <div class="input"><input name="<?=$i;?>" type="text" value="<?=contact_form_post($i);?><?=$slash;?>></div>
      <?php
      
break;
    case 
'turing':
      
?>
      <div class="input"><input name="<?=$i;?>" type="text" value="<?=contact_form_post($i);?><?=$slash;?>></div>
      <img width="60" height="17" src="<?=$x['url'];?>?sname=<?=session_name();?>&amp;rand=<?=rand();?>" alt="" <?=$slash;?>>
      <br style="clear: both;" <?=$slash;?>>
      <small><?=$x['prompt'];?></small>
      <?php
      
break;
    case 
'upload':
      
?>
      <input name="<?=$i;?>" type="file" value="<?=contact_form_post($i);?><?=$slash;?>>
      <?php
      
if (isset($_SESSION['contact-form-upload'][$i]))
      {
        
?>
        <input name="<?=$i;?>-clear" type="checkbox" value="Yes" <?=$slash;?>>
        <?=$contact_form_msg_clear;?> <?=$_SESSION['contact-form-upload'][$i]['name'];?>
        <?php
      
}
      break;
    case 
'checkbox':
      
?>
      <input name="<?=$i;?>" type="checkbox" value="Yes" <?=contact_form_post($i) ? 'checked="checked"' '';?> <?=$slash;?>>
      <small><?=$x['prompt'];?></small>
      <?php
      
break;
    case 
'textarea':
      
?>
      <div class="input"><textarea name="<?=$i;?>" cols="45" rows="6"><?=contact_form_post($i);?></textarea></div>
      <?php
      
break;
    case 
'select':
    case 
'department':
      
?>
      <select name="<?=$i;?>">
      <option value=""><?=$x['default'];?></option>
      <?php foreach ($x['items'] as $j => $y) { ?><option value="<?=$y;?><?=contact_form_post($i) === $y 'selected="selected"' '';?>><?=$y;?></option><?php ?>
      </select>
      <?php
      
break;
  }
  
?>
  </td>
  </tr>
  <?php
}

?>

<tr><th></th><td><input id="submit_contact" class="submit" type="submit" value="<?=$contact_form_msg_submit;?><?=$slash;?>></td></tr>

</table>
</form>


</div>

And this is the code that you put on whatever page you want the contact form on (in this case it is here Turn of the Decade Masquerade Ball)

PHP Code:

<?php


$contact_form_fields 
= array(
  array(
'name'    => 'Name (first and last):',
        
'type'    => 'name',
        
'require' => 1),
  array(
'name'    => 'I will attend:',
        
'type'    => 'select',
        
'require' => 1,
        
'default' => '-',
        
'items'   => array('Yes',
                           
'No')),
  array(
'name'    => 'My spouse or guest will attend:',
        
'type'    => 'select',
        
'require' => 1,
        
'default' => '-',
        
'items'   => array('Yes',
                           
'No')),
  array(
'name'    => 'I plan to book at the Cypress Hotel:',
        
'type'    => 'select',
        
'require' => 1,
        
'default' => '-',
        
'items'   => array('Yes',
                           
'No',
                           
'Maybe')),
  array(
'name'    => 'E-mail Address:',
        
'type'    => 'email',
        
'require' => 1),
  array(
'name'    => 'Mobile Phone:',
        
'type'    => 'input',
        
'require' => 1));

$contact_form_graph          false;
$contact_form_xhtml          true;

$contact_form_email          "info@turnofthedecade.com";
$contact_form_encoding       "utf-8";
$contact_form_message_prefix "RSVP Information\r\n______________________________________________\r\n\r\n";

include_once 
"contact-form.php";

?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 09-03-09, 08:57 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Check to see if they were blocked as spam.

It may be that the from and to addresses are the same?

<? is a short tag, it is better to use <?php. That is not an issue in this case, it is being processed properly (I checked the link).

PHP Code:

"<?=$_SERVER['REQUEST_URI'];?>"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 09-03-09, 09:04 PM
thinktec thinktec is offline
Newbie Coder
 
Join Date: Sep 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
According to my mail error log this is the error it's showing...

2009 Sep 03 19:52:36 Result: 9
2009 Sep 03 19:52:36 From address not in member domain. Message not sent.

What the heck does that mean? The from address is from info@turnofthedecade.com which is indeed part of the member domain.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 09-04-09, 08:27 AM
therocket954's Avatar
therocket954 therocket954 is offline
Community Liaison
 
Join Date: Jul 2007
Location: Michigan, USA
Posts: 334
Thanks: 2
Thanked 8 Times in 8 Posts
I worked on a site once that was hosted by Yahoo Small Business.... I remember they had to specify the "sender" email address somehwere in the control panel, which also had to be coming from the hosted domain name. This setting was in addition to the script's reference to the . (In addition to the mail script I wrote for them).

I don't have Control Panel access for Yahoo for any sites at the moment to cite specific examples, but I do remember that in order to get it working, we had to have it being sent "to" AND "from" a domain related email address. It would fail if we would try and CC another external email address (such as the visitor filling out the form).
__________________
--Eric Allison
Twitter: http://www.twitter.com/Eric_Allison
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 11-18-09, 04:41 PM
GibbonsPi GibbonsPi is offline
New Member
 
Join Date: Nov 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Problem With Script

Im using GoDaddy as my hosting server and am trying to get my webform to send correctly. Ive recently built my first website, Gibbonspi.com which is a family business. When trying to retrieve credit card info about our clients when the submit button is clicked I get an email but from this address detectiveserv@p3nlhssl028.shr.prod.p...reserv er.net rather than the one typed into my text field box. I also get all the subjects from top to bottom such as Name on Card and Security code but nothing that has been typed into the text fields show up in the emails. I have checked the script numerous amounts of times and am starting to think its not me it has something to do with the hosting.... here is the script
PHP Code:

<?php


/* Subject and Email Variables */

    
$emailSubject 'New Client Request';
    
$webMaster 'Anthony@Gibbonspi.com';
    
/* Gathering Data Varianbles */

    
$emailField $_POST['email'];
    
$nameField $_POST['name'];
    
$cardnumberField $_POST['cardnumber'];
    
$securitycodeField $_POST['securitycode'];
    
$expireField $_POST['expire'];
    
$cardtypeField $_POST['cardtype'];
    
$agreeField $_POST['agree'];
    
    
$body = <<<EOD
<br><hr><br>
Email: 
$email <br>
Name: 
$name <br>
Card Number: 
$cardnumber <br>
Security Code: 
$securitycode <br>
Expiration Date: 
$expire <br>
Card Type: 
$cardtype <br>
Agree: 
$agree <br>
EOD;

    
$headers "From: $email\r\n";
    
$headers .= "Content-type: text/html\r\n"
    
$success mail($webMaster$emailSubject$body$headers); 
    
?>
Like i said the only things that do not show up in the email is the correct FROM address or any of the text field answers..... Ive tried everything that I know of can anyone please help... I use Dreamweaver CS4....

Thanks

Last edited by wirehopper; 11-18-09 at 10:15 PM. Reason: PHP tags
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 11-18-09, 10:20 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
I don't think this is PCI compliant.

https://www.pcisecuritystandards.org/
https://www.pcisecuritystandards.org/saq/index.shtml
https://www.pcisecuritystandards.org/docs/pci_saq_a.doc

I recommend you take the payment page down and ensure you are PCI compliant before accepting and transmitting credit card data.

A good solution may be to use PayPal (http://paypal.com). It is secure, established, and accepted.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 11-19-09, 09:32 AM
GibbonsPi GibbonsPi is offline
New Member
 
Join Date: Nov 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Yeah, we looked into paypal but the only problem is we never know the transaction amount until we talk to the client. There is no SET service fee it all depends on the time we spend on each case and we use a pay first get results later. So to use paypal we think it would just be a mess whereas if we have the clients credit card info. on file we can charge without the client having to go through different payment periods. We have a business account through Bank of America and thought that what we have would be the easiest way to go about things. Again, this is my first walk in the park so any and all information I get will be very useful on this subject. As far as the script goes, does anyone know why when the submit button is clicked with all text fields filled I get an email from detectiveserv@p3nlhssl028.shr.prod.p...reserv er.net rather than the clients input address and no text field info. is presented in the Email?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 11-19-09, 02:24 PM
therocket954's Avatar
therocket954 therocket954 is offline
Community Liaison
 
Join Date: Jul 2007
Location: Michigan, USA
Posts: 334
Thanks: 2
Thanked 8 Times in 8 Posts
So... you don't negotiate with the client how much you're going to charge them?

You can use some fairly simple scripts that allow the client to type in an amount to pay, and then use Paypal to process that amount the client types in. (You don't have to "preset" values from within Paypal).
__________________
--Eric Allison
Twitter: http://www.twitter.com/Eric_Allison
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


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

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 11:17 AM
PHP Programmer - Form Metic Job Offers & Assistance 13 06-29-06 08:03 AM
Installing PHP on Windows 2003 server NoMercy PHP 2 01-07-06 11:49 PM
Need PHP contact form eMax Job Offers & Assistance 4 03-22-05 01:16 PM
[For Hire] Freelance PHP Programmer/Web Designer 3+ yrs exp Czaries Job Offers & Assistance 0 01-04-05 01:53 PM


All times are GMT -5. The time now is 10:52 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.