Jump to content

Can anyone help me get this working?


codieB

Recommended Posts

I posted yesterday. Seems this one might be a doozy. Almost ALL of the functionality is working save one.

 

he purpose of this code is to get people to enter information in order to receive a "key" for access to a video archive. After pushing SUBMIT, they get an automated email response providing them with the link. THIS WORKS! Plus, I get a BCC, so I know what email addresses these are going to.

 

WHAT DOESN"T WORK is the greeting, "Congratulations (Name). Please see following code. Your help would be GREATLY appreciated.  :)

 

no space
<?php
$menu1 = "none";
$menu2 = "none";
$menu3 = "none";
?>


<?php include '../../inc/pageheadhome.inc'; ?>

<body id="home" class="colSM">


<?php include '../../inc/header_home.inc'; ?>

<? // This is correctly indented ?>

<div id="colmain3">



<div class="col3">
  <div><div>
    <dl>
        
<table id="Table_01" background="FACES_register/facesVideo.jpg"  width="772" height="585" border="0" cellpadding="0" cellspacing="0">

    <tr valign="middle">
	<td width="194" valign=""> </td>
	<td width="561"><table><tr><td colspan="3"><table width="543">
	  <tr><td width="528" height="188px"> </td>
	</tr>
	  <tr><td>



  <?php
       
       
function spamcheck($field)


  {
  //filter_var() sanitizes the e-mail
  //address using FILTER_SANITIZE_EMAIL
  $field=filter_var($field, FILTER_SANITIZE_EMAIL);

  //filter_var() validates the e-mail
  //address using FILTER_VALIDATE_EMAIL
  if(filter_var($field, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
  else
    {
    return FALSE;
    }
  }
if (isset($_REQUEST['email']))
  {//if "email" is filled out, proceed
  //check if the email address is invalid
  $mailcheck = spamcheck($_REQUEST['email']);
  if ($mailcheck==FALSE)
    {
    echo "Invalid input";
    }
  else
    {//send email
   
   
    $Name = "name"; //senders name
   $email = "from.mycompany.com"; //senders e-mail adress
   $recipient = $_REQUEST['email']; //recipient
   $reply = "Congratulations! Video access for " .$_POST['fname']." ".$_POST['lname']."";
   
$mail_body = "body content"; //mail body //mail body

   $subject = "Video Access"; //subject
   $headers = "From: ". $Name . " <" . $email . ">\r\nbcc: blind@company.com\r\n"; //optional headerfields
   $headers .= "BCC: blindm@company.com\r\n";

   mail($recipient, $subject, $mail_body, $reply, $headers); //mail command 

    	echo "<font size='3'><font color='#c61317'><strong>Thank you.</font></strong> Please check your email for the access link.</font>";
    }
  }
else
  {//if "email" is not filled out, display the form
  echo "<form method='post' action='videoAccess.php'>
  To gain access to the video archive, please fill out the form below.<br /><br />
  First Name: <input name='fname' type='text' /><br />
  Last Name: <input name='lname' type='text' /><br />
  Email: <input name='email' type='text' /><br /><br />
  Subject: <strong>Access to FACES archive</strong><br /><br />
  
  

  <input type='submit' />
  </form>";
  }
?>

no space

Link to comment
Share on other sites

The PHP mail command: http://uk.php.net/manual/en/function.mail.php

 

The fifth parameter is for additional headers.

 

   $subject = "Video Access"; //subject
   $headers = "From: ". $Name . " <" . $email . ">\r\n"; //bcc: blind@company.com\r\n"; //optional headerfields
   //$headers .= "BCC: blindm@company.com\r\n";

   mail($recipient, $subject, $mail_body, $headers); //mail command 

 

See how that works for now.

Link to comment
Share on other sites

if (isset($_REQUEST['email']))
  {//if "email" is filled out, proceed
  //check if the email address is invalid
  $mailcheck = spamcheck($_REQUEST['email']);
  print_r($_REQUEST); 
  die();

 

Replace that portion of the code with that and report back what is printed to the screen.

 

EDIT:

ALso noticed the mail function is wrong.

mail($recipient, $subject, $mail_body, $reply, $headers); //mail command 

SHOULD BE

mail($recipient, $subject, $mail_body . $reply, $headers); //mail command 

Link to comment
Share on other sites

I want to see what this code produces

if (isset($_REQUEST['email']))
  {//if "email" is filled out, proceed
  //check if the email address is invalid
  $mailcheck = spamcheck($_REQUEST['email']);
  print_r($_REQUEST); // note added this
  die(); // note added this.

 

To make sure the $_REQUEST array has the values it needs to have. Run that and then paste the array that is returned.

Link to comment
Share on other sites

OK. Let's see if I am following directions correctly. I copy/pasted the code you provided and tested the form in Firefox and Safari. It seemed like business as usual with no error messages. Array returned? None, I think.

 

Does this comply with your statement: "Run that and then paste the array that is returned."

 

Link to comment
Share on other sites

Adding that code should return an Array( setup, not "business as usual"

 

<?php
$menu1 = "none";
$menu2 = "none";
$menu3 = "none";
?>


<?php include '../../inc/pageheadhome.inc'; ?>

<body id="home" class="colSM">


<?php include '../../inc/header_home.inc'; ?>

<? // This is correctly indented ?>

<div id="colmain3">



<div class="col3">
     <div><div>
       <dl>
       
<table id="Table_01" background="FACES_register/facesVideo.jpg"  width="772" height="585" border="0" cellpadding="0" cellspacing="0">
   
    <tr valign="middle">
      <td width="194" valign=""> </td>
      <td width="561"><table><tr><td colspan="3"><table width="543">
        <tr><td width="528" height="188px"> </td>
      </tr>
        <tr><td>
      


  <?php
       
       
function spamcheck($field)


  {
  //filter_var() sanitizes the e-mail
  //address using FILTER_SANITIZE_EMAIL
  $field=filter_var($field, FILTER_SANITIZE_EMAIL);

  //filter_var() validates the e-mail
  //address using FILTER_VALIDATE_EMAIL
  if(filter_var($field, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
  else
    {
    return FALSE;
    }
  }
if (isset($_REQUEST['email']))
  {

  print_r($_REQUEST); // note added this
  die(); // note added this.

//if "email" is filled out, proceed
  //check if the email address is invalid
  $mailcheck = spamcheck($_REQUEST['email']);
  if ($mailcheck==FALSE)
    {
    echo "Invalid input";
    }
  else
    {//send email
   
   
    $Name = "name"; //senders name
   $email = "from.mycompany.com"; //senders e-mail adress
   $recipient = $_REQUEST['email']; //recipient
   $reply = "Congratulations! Video access for " .$_POST['fname']." ".$_POST['lname']."";
   
$mail_body = "body content"; //mail body //mail body

   $subject = "Video Access"; //subject
   $headers = "From: ". $Name . " <" . $email . ">\r\nbcc: blind@company.com\r\n"; //optional headerfields
   $headers .= "BCC: blindm@company.com\r\n";

   mail($recipient, $subject, $mail_body . $reply, $headers); //mail command 

       echo "<font size='3'><font color='#c61317'><strong>Thank you.</font></strong> Please check your email for the access link.</font>";
    }
  }
else
  {//if "email" is not filled out, display the form
  echo "<form method='post' action='videoAccess.php'>
  To gain access to the video archive, please fill out the form below.<br /><br />
  First Name: <input name='fname' type='text' /><br />
  Last Name: <input name='lname' type='text' /><br />
  Email: <input name='email' type='text' /><br /><br />
  Subject: <strong>Access to FACES archive</strong><br /><br />
  
  

  <input type='submit' />
  </form>";
  }
?>

 

Use that code and see what it returns, it should not do any processing, but display a white page with an array element printed out to the screen.

Link to comment
Share on other sites

I'm sorry. I'm just not getting a white screen. When you say RUN the page, you mean test it in a browser, right? I get the form with input fields.

 

Yes, fill in the inputs and submit the form.

 

When it hits the section I put in there it will die and print out an array to the screen.

Link to comment
Share on other sites

Are you even uploading the new version of the script?

 

It seems like you are not uploading any corrected version and it is staying as the old version, hence why none of the solutions worked.

 

Try this version, since you got the array message now and you know the fields are populated:

<?php
$menu1 = "none";
$menu2 = "none";
$menu3 = "none";
?>


<?php include '../../inc/pageheadhome.inc'; ?>

<body id="home" class="colSM">


<?php include '../../inc/header_home.inc'; ?>

<? // This is correctly indented ?>

<div id="colmain3">



<div class="col3">
     <div><div>
       <dl>
       
<table id="Table_01" background="FACES_register/facesVideo.jpg"  width="772" height="585" border="0" cellpadding="0" cellspacing="0">
   
    <tr valign="middle">
      <td width="194" valign=""> </td>
      <td width="561"><table><tr><td colspan="3"><table width="543">
        <tr><td width="528" height="188px"> </td>
      </tr>
        <tr><td>
     


  <?php
       
       
function spamcheck($field)


  {
  //filter_var() sanitizes the e-mail
  //address using FILTER_SANITIZE_EMAIL
  $field=filter_var($field, FILTER_SANITIZE_EMAIL);

  //filter_var() validates the e-mail
  //address using FILTER_VALIDATE_EMAIL
  if(filter_var($field, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
  else
    {
    return FALSE;
    }
  }
if (isset($_REQUEST['email']))
  {

//if "email" is filled out, proceed
  //check if the email address is invalid
  $mailcheck = spamcheck($_REQUEST['email']);
  if ($mailcheck==FALSE)
    {
    echo "Invalid input";
    }
  else
    {//send email
   
   
    $Name = "name"; //senders name
   $email = "from.mycompany.com"; //senders e-mail adress
   $recipient = $_REQUEST['email']; //recipient
   $reply = "Congratulations! Video access for " .$_POST['fname']." ".$_POST['lname']."";
   
$mail_body = $reply . "body content"; //mail body //mail body

   $subject = "Video Access"; //subject
   $headers = "From: ". $Name . " <" . $email . ">\r\nbcc: blind@company.com\r\n"; //optional headerfields
   $headers .= "BCC: blindm@company.com\r\n";

   mail($recipient, $subject, $mail_body, $headers); //mail command 

       echo "<font size='3'><font color='#c61317'><strong>Thank you.</font></strong> Please check your email for the access link.</font>";
    }
  }
else
  {//if "email" is not filled out, display the form
  echo "<form method='post' action='videoAccess.php'>
  To gain access to the video archive, please fill out the form below.<br /><br />
  First Name: <input name='fname' type='text' /><br />
  Last Name: <input name='lname' type='text' /><br />
  Email: <input name='email' type='text' /><br /><br />
  Subject: <strong>Access to FACES archive</strong><br /><br />
  
  

  <input type='submit' />
  </form>";
  }
?>

 

And make sure that the correct version gets uploaded. That should work.

Link to comment
Share on other sites

Yes. I had been uploading the file to the server, but I copy/pasted your code and tried again---------------same results.

 

I'm starting to suspect that it is a server thing and not the code. We use BlueHost.

 

When I send the file locally, everything goes right.

1. The recipient receives the email

2. The person's name is included in the "Congratulations" message

3. The body comes in just fine

3. I get a BCC

 

The only thing is, instead of the email appearing in my inbox with the name of the sender (included in script) the inbox indicates World Wide Web Server.

 

What do you make of this?

 

Thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.