Jump to content

asdgq9

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

asdgq9's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I want to post a simple comments box at the bottom of one of my web pages that will send the data from 4 different inputs, named "email," "name," "comments," and "telephone," to my email. Can someone look at my php code and see what is wrong? The website code box works great if I enter in all the fields, however if the email box is not filled out and you click the submit button, it displays "Invalid email address enteredThank you for your message, we will be in touch shortly" How do I get rid of "Thank you for your message, we will be in touch shortly" Also, it sends the email even if the ['Name'] tag is not filled out, I not sure how to make it required. By the way, I'm new to php, so sorry if this is a little hard to understand. Link to website: http://www.raysmasonryconcrete.com/contact.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Send Data Form</title> </head> <body> <?php if(!$_POST) exit; $email = $_POST['Email']; $name = $_POST['Name']; $telephone = $_POST['Telephone']; $comments = $_POST['Comments']; //$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','Telephone','Comments'); $required = array('Name','Email','Telephone','Comments'); $your_email = "*****"; $email_subject = "Message From the HDS Builders Website:"; foreach($values as $key => $value){ if(in_array($value,$required)){ if ($key != 'Name' && $key != 'Comments' && $key != 'Telephone') { if( empty($_POST[$value]) ) { echo 'Please go back and complete all fields, thank you.'; exit; } } $email_content .= $value.': '.$_POST[$value]."\n"; } } } $headers = "From: $email\r\n"."Reply-To: $email\r\n".'X-Mailer: PHP/' . phpversion(); if(@mail($your_email, $email_subject, $email_content, $headers)) { echo 'Thank you for your message, we will be in touch shortly'; } else { echo 'ERROR!'; } ?> </body> </html>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Send Data Form</title> </head> <body> <?php if(!$_POST) exit; $email = $_POST['Email']; $name = $_POST['Name']; $telephone = $_POST['Telephone']; $comments = $_POST['Comments']; //$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 )){ $errors=1; } if($errors==1) echo $error; else{ $values = array ('Name','Email','Telephone','Comments'); $required = array('Name','Email','Telephone','Comments'); $your_email = "****************"; $email_subject = "Comment posted from website:"; foreach($values as $key => $value){ if(in_array($value,$required)){ if ($key != 'Name' && $key != 'Comments' && $key != 'Telephone') { if( empty($_POST[$value]) ) { echo 'Please go back and complete all fields, thank you.'; exit; } } $email_content .= $value.': '.$_POST[$value]."\n"; } } } $headers = "From: $email\r\n"."Reply-To: $email\r\n".'X-Mailer: PHP/' . phpversion(); mail($your_email, $email_subject, $email_content, $headers); if($send_contact){ echo "Thank you for your submission"; } else { echo "ERROR, your comment was not sent"; ?> </body> </html> MOD EDIT: . . . tags added.
  3. Hi, I want to post a simple comments box at the bottom of one of my web pages that will send the data from 3 different inputs, named "name," "costumer_mail," and "detail," to my email, but I am new to php. Can someone look at my php code and see what is wrong? I'm having trouble trying to find a spot to put the input "name" in the php. PHP: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Send Data Form</title> </head> <body> <?php // Contact subject $subject='Comment Posted From Website'; // Details $message=$_POST['detail']; // Mail of sender // From $headers=$_POST['customer_mail']; // Enter your email address $to ='******my e-mail address*****'; { mail($to,$subject,$message,$headers); } // Check, if message sent to your email // display message "Thank you for your submission" if($send_contact){ echo "Thank you for your submission"; } else { echo "ERROR, your comment was not sent"; } HTML form: <form method="post" action="send_contact.php" name="comment_form"> <table cellspacing="0" style="width: 153%" class="style6"> <tr> <td style="width: 286px; height: 29px;">Name:</td> <td style="height: 29px"> <input name="name" type="text" style="width: 250px; height: 22px"/> </td> </tr> <tr> <td style="width: 286px">E-mail Address/Phone Number:</td> <td> <input name="customer_mail" type="text" class="style4"style="width: 250px; height: 22px" /> </td> </tr> <tr> <td colspan="2" class="style5"> <textarea name="detail" style="width: 582px; height: 157px"></textarea> </td> </tr> <tr> <td colspan="2" class="style7" valign="top"> <input type="submit" name="Submit" style="width: 87px" value="submit" /> </td> </tr> </table> </form>
×
×
  • 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.