DPChallenge: A Digital Photography Contest You are not logged in. (log in or register
 

DPChallenge Forums >> General Discussion >> Any CSS coders out there: Help?
Pages:  
Showing posts 1 - 16 of 16, (reverse)
AuthorThread
03/26/2012 08:20:35 AM · #1
This is what I have set up for my form on my website






























Now, I just can't figure out what the code is for making sure I get sent the information to MY email address...with all the relevant information...can anyone help?
03/26/2012 08:40:04 AM · #2
Do you have a script called contact.php? - This is what actually sends the email.
03/26/2012 09:03:57 AM · #3
Yup...I'm just taking a look at it now...didn't realize I had it in my folder.
03/26/2012 09:07:09 AM · #4
Looks like this


if(!$_POST) exit;

$email = $_POST['email'];

//$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]

{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-]

[a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
$error.="Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$values = array ('name','email','message');
$required = array('name','email','message');

$your_email = "info@studiof7.com";
$email_subject = "New Message: ".$_POST['subject'];
$email_content = "new message:\n";

foreach($values as $key => $value){
if(in_array($value,$required)){
if ($key != 'subject' && $key != 'company') {
if( empty($_POST[$value]) ) { echo 'PLEASE FILL

IN REQUIRED FIELDS'; exit; }
}
$email_content .= $value.': '.$_POST[$value]."\n";
}
}

if(@mail($your_email,$email_subject,$email_content)) {
echo 'Message sent!';
} else {
echo 'ERROR!';
}
}
?>

I'm getting an error though...not sure what to change...
03/26/2012 09:15:00 AM · #5
First, I *think* the recipient email address is $your_email = "info@studiof7.com";

It looks like it's using a function called @mail() to actually send the email. Is it failing at that point?

Has this worked for you before? - You need to make sure your mail server is setup correctly to send out emails. (There are a few different ways to send emails programatically) - It depends on where you're hosting your site, whether it's windows/linux etc..
03/26/2012 09:40:08 AM · #6
This is my first attempt.

As soon as I fill out the information and click the send button, I get this error:

$value){ if(in_array($value,$required)){ if ($key != 'subject' && $key != 'company') { if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; } } $email_content .= $value.': '.$_POST[$value]."\n"; } } if(@mail($your_email,$email_subject,$email_content)) { echo 'Message sent!'; } else { echo 'ERROR!'; } } ?>

03/26/2012 11:28:50 AM · #7
That's not really an error, it's just spitting out a chunk of that php at you. To me it looks like your web server isn't actually running the php code properly. (i.e. instead of running the php, it just displays the file)

Here's a simple test to make sure php is running on your web server. First, do this. If this works, then the problem is elsewhere. //www.gilesorr.com/papers/PHP/x37.html
03/26/2012 11:58:21 AM · #8
Yup, agree with John that you need to make sure PHP is actually running first. Oh, and delete the info.php file afterwards as its gold dust to the bad people out there.
03/26/2012 12:58:39 PM · #9
Also, this isn't CSS coding, LOL.
03/26/2012 06:55:12 PM · #10
Originally posted by code:

//$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]

{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-]

[a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){


It may just be the way you have pasted it but this should be two lines rather than 4 with returns between them.

Like this,

//$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){

Though the first line is commented out and the script seems to work with or without it.

If it is spitting out the lines of code you have posted above as an 'error' there is something wrong somewhere with something that wasn't posted, the script works OK for me.

And if it helps, as Don said it isn't CSS its PHP ;)
03/27/2012 04:41:39 AM · #11
Yeah, it works.

Sorry for my lack of knowledge here...I was testing it out without having the actual files on my server to see what would happen. Once on the server, it all worked just fine. Thanks for all the help guys!
03/27/2012 08:50:40 AM · #12
That's great.

If you want to test websites that contain PHP or any other server-side code, then it is possible to setup a local web server on your PC (you can install Apache, MySQL, PHP etc.)

But most of the time it's just as easy to upload it to your actual webserver, and test it there.
03/27/2012 10:26:12 AM · #13
as a general rule, you can't test forms until you put them on the server.

(unless you go JH's route, which is rather ambitious. you would be turning your own computer into a server.)
03/27/2012 10:31:00 AM · #14
Originally posted by JH:

That's great.

If you want to test websites that contain PHP or any other server-side code, then it is possible to setup a local web server on your PC (you can install Apache, MySQL, PHP etc.)

But most of the time it's just as easy to upload it to your actual webserver, and test it there.


XAMP - Virtual WebServer on a local machine
03/27/2012 10:35:07 AM · #15
I've stopped using XAMP myself as even though I ensure the PHP/mySQL is the same version as the live server I often run into problems when putting a site 'live'. I find it much easier to put aside some live space for a sandpit then I only need to 'fix' things once.
03/27/2012 12:25:18 PM · #16
I agree. I only use it now for testing and really early dev stages. I would rather throw the site up on a live server and fix it there than working out all the kinks locally only to realize it wont work on a live box...

Pages:  
Current Server Time: 08/14/2025 07:08:06 AM

Please log in or register to post to the forums.


Home - Challenges - Community - League - Photos - Cameras - Lenses - Learn - Help - Terms of Use - Privacy - Top ^
DPChallenge, and website content and design, Copyright © 2001-2025 Challenging Technologies, LLC.
All digital photo copyrights belong to the photographers and may not be used without permission.
Current Server Time: 08/14/2025 07:08:07 AM EDT.