From: Watson Blair on 26 Apr 2010 15:16 Hey guys, so ive coded a sucessfull contact form before, but for some reason this bit of code is giving me the run-arroundl.... so my HTML end is: <form action="send.php" method="post" enctype="multipart/form-data"> <table border="0" cellspacing="2" cellpadding="0"> <tr><td style="text-align:left;"> Send E-mail to: </td> <td><input type="radio" name="to" value=" bestudios.wb(a)gmail.com">General Information</td></tr> <tr><td></td><td><input type="radio" name="to" value=" ajaganji(a)akwimemorial.org">Founder and President: Professor Ajagi Nji, Ph.D</td></tr> <tr><td></td><td><input type="radio" name="to" value=" dtanwani(a)akwimemorial.org">Executive Secretary: Dorothy Tah Tanwani</td></tr> <tr><td style="text-align:left;"> Name: </td> <td><input type="text" name="name" size="40"></tr></td> <tr><td style="text-align:left;">Subject: </td> <td><input type="text" name="subject" size="40"/></td></tr> <tr><td style="text-align:left;">E-mail Address: </td> <td><input type="text" name="from" size="40"/></td></tr> <tr><td style="text-align:left;">Message: </td> <td><TEXTAREA NAME="message" COLS=31 ROWS=7></TEXTAREA></td></tr> <tr><td></td><td style="text-align:center;"> </td></tr> <tr><td colspan="2" style="text-align:right;"><input type="submit" value="Send E-mail" name="submit" /></td></tr> </form></table> and the file send.php is: <?php $subject =$_POST"subject"; $message=$_POST"message"; $name=$_POST"name"; $from=$_POST"from" $mail_from=$_POST"from"; $to =$_POST"to"; $header = "From: {$name} < {$from} >"; $send_contact=mail($to,$subject,$message, $header); if($send_contact){ echo "Thank you for Contacting Us!"; } else { echo "An error occurred while sending your message, review your information and please try again."; } ?> when i go to test it out all i get back is a blank screen with: "; $send_contact=mail($to,$subject,$message, $header); if($send_contact){ echo "Thank you for Contacting Us!"; } else { echo "An error occured while sending your message, review your information and please try again."; } ?> on it... when i take out the like " $header = "From: {$name} < {$from} >";" i just get a blank screen, but it dosen't send the e-mail.... i know i'm missing something really obvious, but i just can't see it. Thanks, Watson
From: Adam Richardson on 26 Apr 2010 15:26 On Mon, Apr 26, 2010 at 3:16 PM, Watson Blair <bestudios.wb(a)gmail.com>wrote: > Hey guys, so ive coded a sucessfull contact form before, but for some > reason > this bit of code is giving me the run-arroundl.... > > so my HTML end is: > > > <form action="send.php" method="post" enctype="multipart/form-data"> > <table border="0" cellspacing="2" cellpadding="0"> > <tr><td style="text-align:left;"> Send E-mail to: > </td> > <td><input type="radio" name="to" value=" > bestudios.wb(a)gmail.com">General Information</td></tr> > <tr><td></td><td><input type="radio" name="to" value=" > ajaganji(a)akwimemorial.org">Founder and President: Professor Ajagi Nji, > Ph.D</td></tr> > <tr><td></td><td><input type="radio" name="to" value=" > dtanwani(a)akwimemorial.org">Executive Secretary: Dorothy Tah > Tanwani</td></tr> > <tr><td style="text-align:left;"> Name: </td> > <td><input type="text" name="name" size="40"></tr></td> > <tr><td style="text-align:left;">Subject: </td> > <td><input type="text" name="subject" > size="40"/></td></tr> > <tr><td style="text-align:left;">E-mail Address: > </td> > <td><input type="text" name="from" size="40"/></td></tr> > <tr><td style="text-align:left;">Message: </td> > <td><TEXTAREA NAME="message" COLS=31 > ROWS=7></TEXTAREA></td></tr> > <tr><td></td><td style="text-align:center;"> > > </td></tr> > <tr><td colspan="2" style="text-align:right;"><input > type="submit" value="Send E-mail" name="submit" /></td></tr> > </form></table> > > and the file send.php is: > > <?php > > $subject =$_POST"subject"; > > $message=$_POST"message"; > > $name=$_POST"name"; > > $from=$_POST"from" > > $mail_from=$_POST"from"; > > $to =$_POST"to"; > > $header = "From: {$name} < {$from} >"; > > $send_contact=mail($to,$subject,$message, $header); > > if($send_contact){ > echo "Thank you for Contacting Us!"; > } > else { > echo "An error occurred while sending your message, review your information > and please try again."; > } > ?> > > when i go to test it out all i get back is a blank screen with: "; > $send_contact=mail($to,$subject,$message, $header); if($send_contact){ echo > "Thank you for Contacting Us!"; } else { echo "An error occured while > sending your message, review your information and please try again."; } ?> > on it... when i take out the like " > $header = "From: {$name} < {$from} >";" i just get a blank screen, but it > dosen't send the e-mail.... i know i'm missing something really obvious, > but > i just can't see it. > Thanks, > Watson > Maybe you just miscopied, but are you missing the brackets on the post array vars (e.g., $from=$_POST["from"]) ? Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
From: Dan Joseph on 26 Apr 2010 15:30 Looks like you might have errors turned off. I see: $subject =$_POST"subject"; Which should be: $subject =$_POST["subject"]; $_POST is an array, and that's how you access those elements. check to see if errors are on, if not, you'll see errors in the log files. -- -Dan Joseph www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month. Promo Code "NEWTHINGS" for 10% off initial order http://www.facebook.com/canishosting http://www.facebook.com/originalpoetry
From: Watson Blair on 26 Apr 2010 15:46 I knew i was missing something.... although it still doesn't work... i'm still getting : "; $send_contact=mail($to,$subject,$message, $header); if($send_contact){ echo "Thank you for Contacting Us!"; } else { echo "An error occured while sending your message, review your information and please try again."; } ?> would it make a difference that i'm running it off of my computer rather than hosting it online? Thanks, Watson On Mon, Apr 26, 2010 at 3:30 PM, Dan Joseph <dmjoseph(a)gmail.com> wrote: > Looks like you might have errors turned off. I see: > > $subject =$_POST"subject"; > > Which should be: > > $subject =$_POST["subject"]; > > $_POST is an array, and that's how you access those elements. check to see > if errors are on, if not, you'll see errors in the log files. > > -- > -Dan Joseph > > www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month. Promo > Code "NEWTHINGS" for 10% off initial order > > http://www.facebook.com/canishosting > http://www.facebook.com/originalpoetry >
From: Ashley Sheridan on 26 Apr 2010 16:00
On Mon, 2010-04-26 at 15:46 -0400, Watson Blair wrote: > I knew i was missing something.... although it still doesn't work... i'm > still getting : > > "; $send_contact=mail($to,$subject,$message, $header); if($send_contact){ > echo "Thank you for Contacting Us!"; } else { echo "An error occured while > sending your message, review your information and please try again."; } ?> > > would it make a difference that i'm running it off of my computer rather > than hosting it online? > > Thanks, > Watson > > On Mon, Apr 26, 2010 at 3:30 PM, Dan Joseph <dmjoseph(a)gmail.com> wrote: > > > Looks like you might have errors turned off. I see: > > > > $subject =$_POST"subject"; > > > > Which should be: > > > > $subject =$_POST["subject"]; > > > > $_POST is an array, and that's how you access those elements. check to see > > if errors are on, if not, you'll see errors in the log files. > > > > -- > > -Dan Joseph > > > > www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month. Promo > > Code "NEWTHINGS" for 10% off initial order > > > > http://www.facebook.com/canishosting > > http://www.facebook.com/originalpoetry > > That might be it if you're running Windows, although a Linux system would usually have sendmail installed by default. Also, make sure you validate your inputs. Don't put the to address as a field within the form, leave that hard coded in your app, just let the radio buttons switch between an array of values in send.php. Putting them in the form like that could let anyone use your form to send email to anywhere they wanted. Also, it's very simple to modify the from field to include as many cc or bcc fields as someone wants, and use your form as a spam relay system. Thanks, Ash http://www.ashleysheridan.co.uk |