PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
trnqlsoljah
Forum Newbie
Posts: 1 Joined: Thu Mar 18, 2010 1:28 pm
Post
by trnqlsoljah » Thu Mar 18, 2010 1:34 pm
whats wrong with this code man? it seems PERFECT...im tryng to get an email out of
http://www.mequonswimschool.com . if u go to the site. i kno my AS3 is right but im not good at php so im assuming my problem is here
Code: Select all
<?php
$contact_name = $_POST['name'];
$contact_email = $_POST['email'];
$contact_subject = $_POST['subject'];
$contact_message = $_POST['message'];
$contact_address = $_POST['address'];
$city_subject = $_POST ['city'];
$state_subject = $_POST ['state'];
$zip_subject = $_POST ['zip'];
$contact_phone = $_POST ['phone'];
if( $contact_name == true )
{
$sender = $contact_email;
$receiver = "info0@mequonswimschoool.com";
$client_ip = $_SERVER['REMOTE_ADDR'];
$email_body = "Name: $contact_name \nEmail: $sender \n\nSubject: $contact_subject \n\nMessage: \n\n$contact_message \n\nIP: $client_ip \n\nFlash Contact Form provided by http://www.flashmo.com";
$email_body_auto_reply = "Hello $contact_name, \nThis is the auto reply message. Thank you. \n\nAdmin - http://www.mequonswimschool.com";
$extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion();
$extra_auto_reply = "From: $receiver\r\n" . "Reply-To: $receiver \r\n" . "X-Mailer: PHP/" . phpversion();
mail( $sender, "Auto Reply - Re: $contact_subject", $email_body_auto_reply, $extra_auto_reply ); // auto reply mail to sender
if( mail( $receiver, "Flash Contact Form - $contact_subject", $email_body, $extra ) )
{
echo "success=yes";
}
else
{
echo "success=no";
}
}
?>
whats wrong with this code man? it seems PERFECT...im tryng to get an email out of
http://www.mequonswimschool.com . if u go to the site. i kno my AS3 is right but im not good at php so im assuming my problem is here
Last edited by
Benjamin on Thu Mar 18, 2010 5:43 pm, edited 1 time in total.
Reason: Added [code=php] tags.
angelicodin
Forum Commoner
Posts: 81 Joined: Fri Nov 13, 2009 3:17 am
Location: Oregon, USA
Post
by angelicodin » Thu Mar 18, 2010 5:25 pm
could you encase the php code with code tags please?
angelicodin
Forum Commoner
Posts: 81 Joined: Fri Nov 13, 2009 3:17 am
Location: Oregon, USA
Post
by angelicodin » Thu Mar 18, 2010 5:39 pm
also what about it is not working? are you getting an error code?
angelicodin
Forum Commoner
Posts: 81 Joined: Fri Nov 13, 2009 3:17 am
Location: Oregon, USA
Post
by angelicodin » Thu Mar 18, 2010 5:45 pm
Right off the bat, at a glance I noticed that you are not concat'ing the var's in the strings.
Code: Select all
<?php
$contact_name = $_POST['name'];
$contact_email = $_POST['email'];
$contact_subject = $_POST['subject'];
$contact_message = $_POST['message'];
$contact_address = $_POST['address'];
$city_subject = $_POST ['city'];
$state_subject = $_POST ['state'];
$zip_subject = $_POST ['zip'];
$contact_phone = $_POST ['phone'];
if( $contact_name == true ){
$sender = $contact_email;
$receiver = "info0@mequonswimschoool.com";
$client_ip = $_SERVER['REMOTE_ADDR'];
$email_body = "Name: ".$contact_name." \nEmail: ".$sender." \n\nSubject: ".$contact_subject." \n\nMessage: \n\n".$contact_message." \n\nIP: ".$client_ip." \n\nFlash Contact Form provided by http://www.flashmo.com";
$email_body_auto_reply = "Hello ".$contact_name.", \nThis is the auto reply message. Thank you. \n\nAdmin - http://www.mequonswimschool.com";
$extra = "From: ".$sender."\r\n" . "Reply-To: ".$sender." \r\n" . "X-Mailer: PHP/" . phpversion();
$extra_auto_reply = "From: ".$receiver."\r\n" . "Reply-To: ".$receiver." \r\n" . "X-Mailer: PHP/" . phpversion();
mail( $sender, "Auto Reply - Re: ".$contact_subject."", $email_body_auto_reply, $extra_auto_reply ); // auto reply mail to sender
if( mail( $receiver, "Flash Contact Form - ".$contact_subject."", $email_body, $extra ) ){
echo "success=yes";
}else{
echo "success=no";
}
}
?>
Try that ^_^
mikosiko
Forum Regular
Posts: 757 Joined: Wed Jan 13, 2010 7:22 pm
Post
by mikosiko » Thu Mar 18, 2010 7:13 pm
Code: Select all
<?php
[color=#FF0000][b]$contact_name = $_POST['name'];[/b][/color]
<<< LINES DELETED JUST FOR CLARITY >>
[color=#FF0000][b]if( $contact_name == true )[/b][/color]
{
$sender = $contact_email;
<< LINES CLEARED >> }
}
?>
Well seems that will work only if your $contact_name is called "true" ....
angelicodin
Forum Commoner
Posts: 81 Joined: Fri Nov 13, 2009 3:17 am
Location: Oregon, USA
Post
by angelicodin » Tue Mar 30, 2010 2:24 pm
Just got your message OP, I fixed up a few things I saw wrong still with the code. also there was a missing quote on a line so the rest of the code until the next quote was thinking it was part of a var string. I also changed the if statement to isset() so if the value has been set from previous page or forum and is not empty this conditional will bool to true. Try not to use == true until you get into more advanced stuff with bool's and making your own functions.
Code: Select all
<?php
$contact_name = $_POST['name'];
$contact_email = $_POST['email'];
$contact_subject = $_POST['subject'];
$contact_phone = $_POST['phone'];
$contact_state = $_POST['state'];
$contact_zip = $_POST['zip'];
$contact_city = $_POST['city'];
$contact_message = $_POST['message'];
if(isset($contact_name) && !empty($contact_name)){
$sender = $contact_email;
$receiver = "ryan_rogers00@yahoo.com";
$client_ip = $_SERVER['REMOTE_ADDR'];
$email_body = "Name: ".$contact_name."\nEmail: ".$sender."\n\nSubject: ".$contact_subject."\n\nMessage:\n\n".$contact_message." ".$contact_state." ".$contact_zip." ".$contact_phone." ".$contact_city."
\n\nIP: ".$client_ip."";
$email_body_auto_reply = "Hello ".$contact_name.", \nThis is the auto reply message. Thank you. \n\nAdmin - http://www.mequonswimschool.com";
$extra = "From: ".$sender."\r\n Reply-To: ".$sender." \r\n X-Mailer: PHP/" . phpversion();
if( mail( $receiver, "Flash Contact Form - ".$contact_subject."",$email_body, $extra ) ){
echo "success=yes";
}else{
echo "success=no";
}
}
?>
try that and let me know, I'll check back here.