Jump to content

newbie needs assistance


ploppy

Recommended Posts

hello. i am trying to understand why this script is not sending mail. here is then php:

 

<?php

/

  /*===================================================
    ShowFormSendMail()
  ===================================================*/

  function ShowFormSendMail() {

    // vars global configuration
    global $dbConn, $theme_path;

    // vars url & form
    global $u, $lid, $revid, $to;

    // vars messages
    global $msg;

    // vars template
    global $error_msg, $email, $name, $body, $subject;

    if ($u) {
      $to = $u;
    }
    elseif ($lid) {
      $to = $dbConn->Lookup('contact_name', 'idx_link', "link_id = '$lid'");
    }
    elseif ($revid) {
      $to = $dbConn->Lookup('username', 'idx_review', "review_id = '$revid'");
      if (!$to) {
        $to = $dbConn->Lookup('name', 'idx_review', "review_id = '$revid'");
      }
    }

    $name    = stripslashes($name);
    $subject = stripslashes($subject);
    $body    = stripslashes($body);

    DisplayTemplate($theme_path . "sendmail_form.html", "\$error_msg,\$email,\$name,\$to,\$u,\$lid,\$revid,\$body,\$subject");
  }


  /*===================================================
    ProcessFormSendMail()
  ===================================================*/
  
  function ProcessFormSendMail() {

    // vars global configuration
    global $dbConn, $theme_path;

    // vars url & form
    global $error_msg, $email, $name, $u, $lid, $revid, $to, $body, $subject;

    // vars messages
    global $msg;

    // vars template
    global $error_msg;

    // verify input

    $name    = stripslashes($name);
    $subject = stripslashes($subject);
    $body    = stripslashes($body);

    if (empty($email))
      $error_msg = $msg["10282"];
    elseif (!IsEmailAddress($email))
      $error_msg = $msg["10283"];

    if (empty($error_msg)) {
      if ($u) {
        $users_obj             = new clsUsers;
        $users_obj->table_name = "idx_users";
        $email_to              = $users_obj->GetEmailAddress($u);
      }
      elseif ($lid) {
        $email_to = $dbConn->Lookup('email', 'idx_link', "link_id = '$lid'");
      }
      elseif ($revid) {
        $email_to = $dbConn->Lookup('email', 'idx_review', "review_id = '$revid'");
        if (!$email_to) {
          $to = $dbConn->Lookup('username', 'idx_review', "review_id = '$revid'");
          $users_obj             = new clsUsers;
          $users_obj->table_name = "idx_users";
          $email_to              = $users_obj->GetEmailAddress($to);
        }
      }
      
      $email_from = $email;
      $from       = $name . "<$email_from>";
      @mail($email_to, $subject, $body, "From: $from \nX-Mailer: INDEXU_X-Mailer/1.0");

      DisplayTemplate($theme_path . "sendmail_ok.html", "\$to,\$u");
    }
    else {
      ShowFormSendMail();
    }
  }


  /*===================================================
    main
  ===================================================*/

  include "application.php";

  RunPreFilter(__FILE__);

  if (empty($pflag)) {
    ShowFormSendMail();
  }
  elseif ($pflag == 'send') {
    ProcessFormSendMail();
  }

  RunPostFilter(__FILE__);

?>

 

here is the sendmail_form.html:

 

<%include file="header.html"
          title="Send Email"
          meta_keywords=""
          meta_description=""
%>

    </td>
  </tr>
  <tr>
    <td>

    <!-- main content here -->

    <br />

    <form action="sendmail.php" method="post">
    <input type="hidden" name="pflag" value="send" />
    <input type="hidden" name="u" value="<%$u%>" />
    <input type="hidden" name="lid" value="<%$lid%>" />
    <input type="hidden" name="revid" value="<%$revid%>" />
    <input type="hidden" name="to" value="<%$to%>" />
      
    <%if $error_msg%>
    <center><p><font color="Red"><b><%$error_msg%></b></font></p></center>
    <%/if%>
      
    <table cellpadding="4" cellspacing="1" border="0" align="center" width="100%" class="tbl_border">
    <tr>
      <td class="tbl_caption" colspan="2">
        Contact Us </td>
    </tr>
    <tr class="tbl_normal">
      <td>Your Name</td>
      <td><input class="text3" type="text" name="name" size="40" value="<%$name%>" /></td>
    </tr>
    <tr class="tbl_normal">
      <td>Your Email Address</td>
      <td><input class="text3" type="text" name="email" size="40" value="<%$email%>" /></td>
    </tr>
    <tr class="tbl_normal">
      <td>To</td>
      <td><b><%$to%></b></td>
    </tr>
    <tr class="tbl_normal">
      <td>Subject</td>
      <td><input class="text3" type="text" name="subject" size="40" value="<%$subject%>" /></td>
    </tr>
    <tr class="tbl_normal">
      <td valign="top">Message</td>
      <td><textarea cols="40" rows="10" name="body" style="overflow: auto;"><%$body%></textarea></td>
    </tr>
    <tr class="tbl_normal">
      <td><img src="captcha.php" alt="" /></td>
      <td><input class="text3" type="text" name="captcha_key" size="40" value="" /></td>
    </tr>
    <tr class="tbl_normal">
      <td>
        <center>
        </center>
      </td>
      <td><input type="submit" name="submit" value="Send Email" /></td>
    </tr>
    </table>

    </form>

    <br />
    <br />

    <!-- end of main content -->

    </td>
  </tr>
  <tr>
    <td>

<%include file="footer.html"%>

 

and the sendmail_ok.html

 

<%include file="header.html"
          title="Send Email"
          meta_keywords=""
          meta_description=""
%>

    </td>
  </tr>
  <tr>
    <td>

    <!-- main content here -->

    <br />
    <b>Send Email</b>
    <p>Your email has been sent to
    <%if $u%>
      <a href="<%$site_url%>/user_detail.php?u=<%$to%>"><%$to%></a>.
    <%else%>
      <%$to%>.
    <%/if%></p>

    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />

    <!-- end of main content -->

    </td>
  </tr>
  <tr>
    <td>

<%include file="footer.html"%>

 

what i am having trouble understanding is that script seems to send the form, but nothing arrives. also the response form to client only states:

 

Send Email 
Your email has been sent to .

and no name there. as i am brand new to php any help would be grately appreciated. many thanks.

Link to comment
https://forums.phpfreaks.com/topic/63569-newbie-needs-assistance/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.