Skip to main content
Participating Frequently
July 6, 2011
Question

Created a form and found simple php script to send results to email doesn't work

  • July 6, 2011
  • 2 replies
  • 1425 views

I've created a form and put it on my site but right now it's only a pseudo form because it does nothing, when submit is hit. I've found this php script and modified it to send the results to my email. When the form's filled out and submit is hit, the visitor is sent to the actual php page, even though they should go to a refreshed version of my site. This is the name of my site ( www.theapartmentinsiders.com ) where the nonfunctioning form resides and here is the php code that I've modified and uploaded into the scripts folder:

<?php

//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.

$subject = 'You have a message from your site';

// Your email address. This is where the form information will be sent.

$emailadd = 'alan@theapartmentinsiders.com';

// Where to redirect after form is processed.

$url = 'http://www.theapartmentinsiders.com';

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.

$req = '0';

// --------------------------Do not edit below this line--------------------------

$text = "Results from form:\n\n";

$space = ' ';

$line = '

';

foreach ($_POST as $key => $value)

{

if ($req == '1')

{

if ($value == '')

{echo "$key is empty";die;}

}

$j = strlen($key);

if ($j >= 20)

{echo "Name of form element $key cannot be longer than 20 characters";die;}

$j = 20 - $j;

for ($i = 1; $i <= $j; $i++)

{$space .= ' ';}

$value = str_replace('\n', "$line", $value);

$conc = "{$key}:$space{$value}$line";

$text .= $conc;

$space = ' ';

}

mail($emailadd, $subject, $text, 'From: '.$emailadd.'');

echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';

?>

If I can get this form to work, I'll be beyond thrilled. By work I mean, e-mail me the results and redirect the site vistor to a designated page.

Thanks in advance.

This topic has been closed for replies.

2 replies

Participating Frequently
July 6, 2011

It's working for me. When I submit, it redirects back to your homepage.

Also, heed what shocker has said about your page design. Making the main content of your homepage out of images is a very bad practice. It's bad for both search engines and visitors.

July 6, 2011

On your website your form action points to /gdform.php

Is that the name of the php file that you provided in the post? gdform.php is a default form script provided by godaddy.

Additionally, your homepage is a single jpeg. This is bad practice. No text is indexed and the large image file takes a very long time to download and display on a visitors browser.

best,

Shocker

Participating Frequently
July 6, 2011

Thank you. Since posting the question, I called my host provider to see if they had php scripts and they did. All I had to do was adjust the form setting to point to their (godaddy) php script (which was alreay in my scripts folder) by simply putting the file name, gd.php in the Action box. After that all I had to do was go to my account on the host's web site to choose an email address for the form contents to be sent to. After all the efforts I made at trying to do the php myself, I'm surprised at how easy this turned out to be. I thought at the very least I'd have to put in individual code for each field within the form.

I do want to recreate my site so that it's no longer image based but I have to figure out how to make it look similar with dw. Until then, is there some kind of way to put text on my site so that it can still be indxed? Perhaps in small font or behind the image or some other method?

July 6, 2011

woops! Thanks. I'll be sure not to do that.

If only the text from the image is used in a legitimate way, I wonder if it's still considered black hat or at least reduced down to grey hat -- not that I'd even intentionally practice either.

What if I used the text from the actual image and pasted that into the alternate text description? Is that acceptable?


bestplaceinaustin wrote:

What if I used the text from the actual image and pasted that into the alternate text description? Is that acceptable?

Acceptable? questionable.

Effective? meh.

Recommended? No.

Replacing text in image is recommended.

best,

Shocker