Jump to content

Email Processor


Syrehn

Recommended Posts

I have a few questions so this post will be a larger one! Sorry, but I'm a bit of a PHP newbie so be gentle with me!  :)

 

Awhile back I wrote out a simple forum to email processor that I used with a few sites I have.  I found this past week or so that all of a sudden they were not working.  I was told that I need to replace any $variable with $_REQUEST[variable].  I did do this as seen in the code below but I found that if I added the $_REQUEST before $timestamp in the $thankyoumessage that the time would not display on the page but it would work if I left it as $timestamp.  The same goes for if I were to include the $subject in the $body.  It will not display if I add $_REQUEST before $subject if I were to add that to the $body. 

 

I was curious to know if someone could tell me why this is?  These processors used to work fine with just $variable.  If I don't use the $_REQUEST for the forum variables it just generates blank responses in the email.

 

 

my current script is: (i'm also aware that the date/time fuctions only works with php 5 and the sites where this processor is being used both use 5)

 

<?php

date_default_timezone_set('America/Edmonton');

$yourEmail = "blank@blank.com";

$subject = "Quote Request";

$body = "Contact Information
\n First Name: $_REQUEST[first_name] \n Last Name: $_REQUEST[last_name] \n Company Name: $_REQUEST[company_name] \n Contact Number: $_REQUEST[contact_number] \n Email Address: $_REQUEST[email] \n Project Information \n Project is: $_REQUEST[project] \n Describe what needs to be done: $_REQUEST[describe] \n Estimate # of Pages: $_REQUEST[number_pages] \n Will you provide a logo: $_REQUEST[provide_logo] \n Will you provide artwork: $_REQUEST[artwork] \n Will you provide body copy: $_REQUEST[body_copy] \n E-commerce features required: $_REQUEST[ecommerce] \n Website Maintanence: $_REQUEST[maintanence] \n Timeframe for completion: $_REQUEST[timeframe]";


$timestamp = date("n/j/Y, \a\\t g:i a T");


$thankyousubject = "Quote Request Submitted Successfully \n on \n $timestamp";


$thankyoumsg = "Thank you $_REQUEST[first_name] $_REQUEST[last_name] for showing interest in designFox Media Works. Please allow 24-48 business hours for a response.";

?>
<?php
mail($yourEmail, $subject, $body, "From: $_REQUEST[first_name] $_REQUEST[last_name] < $_REQUEST[email] >");
print "<CENTER><B><body bgcolor='#000000'><font color='#FFFFFF'> $thankyousubject </B></CENTER><br><br><center>$thankyoumsg</center><BR><BR><CENTER><br><br></font><A HREF=\"http://www.designfoxmediaworks.com\" TARGET=\"_top\"><IMG SRC=\"http://www.designfoxmediaworks.com/images/formbanner.gif\" WIDTH=\"600\" HEIGHT=\"100\" ALT=\"Return to designFox Media Works\" BORDER=\"0\"></A></CENTER></body>"

 

I was also curious in reference to this processor is there a set way to have a timed redirect with php? Or would it be better to look into doing that with javascript?

 

My next question is, if I wanted to have say a rich text editor replace a comment box how would one go about sending that data in the email processor or post it to another page? 

 

 

 

Link to comment
Share on other sites

also, if you want to put arrays straight into strings without concatenating, you should surround the array variable with curly brackets IE

$string = "some strings with an {$array['key']} in it";

 

 

also in emails, you should comply to RFC standards, because emails that don't comply are discarded by isp's a lot (they consider them spam) use \r\n for line breaks (rather than \n) and you should check to see that the post or get (or request in this case) are set before you do anything, to prevent people sending empty emails, and stuff like that

Link to comment
Share on other sites

you need single quotes around the keys in the $_REQUEST.  See if that fixes it.

$_REQUEST['first_name']

Actually, inside of double quotes there's no need to put quotes around the array indexes.

 

Edit: @mikesta707: Similarly, if you're using an array inside of double quotes without quotes on the index it's not necessary to use curly brackets.

 

Variables coming from outside sources like forms or the query string will be in $_POST and $_GET superglobals respectively. The only way that these variables would be pre-defined and work without accessing $_POST, $_GET, or $_REQUEST (which is basically a hybrid of $_GET, $_POST and $_COOKIE superglobals) is if register globals was on (which is a security risk, highly discouraged, depreciated as of PHP 5.3.0). Perhaps there were some changes on your server that caused this happen.

 

For timed refreshes you can do this:

 

header('refresh: 5; url=http://www.phpfreaks.com');

Link to comment
Share on other sites

Thanks for your responses.

 

I will have to check if anything on the servers changed.  Should the $timestamp be working inside the $_REQUEST then? like the other pieces of code are?

 

$_REQUEST before $timestamp in the $thankyoumessage that the time would not display on the page but it would work if I left it as $timestamp. 

Link to comment
Share on other sites

  • 2 weeks later...

I have a friend using the above script. While the above changes work for me on my server in order to get it to work on her webserver she has to use $variable instead of $_REQUEST[variable]

 

Could someone tell me why this is?

 

Also in her emails the processor is listing the word array before each field answer. So for example if she is using:

 

$body = "Name: $name";

 

in her email it says:

 

Name: Array mark smith

 

any ideas?

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.