TomBullock Posted February 3, 2008 Share Posted February 3, 2008 Hello Im starting my own hosting company and i am offering my client to customize thier own packages. I have this code, and i want all the information from it to go to my email. <!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 http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form id="form1" name="Custom Quote Form" method="post" action=""> <u>Contact Information</u><br /> <br /> Name:<br /> <label> <input name="Name" type="text" size="20" /> </label> <br /> E-Mail:<br /> <label> <input name="E-Mail" type="text" size="20" /> </label> <br /> Address:<br /> <label> <input name="Address" type="text" size="20" /> </label> <br /> <label></label> Town:<br /> <label> <input name="Town" type="text" size="20" /> </label> <br /> County:<br /> <label> <input name="County" type="text" size="20" /> </label> <br /> Post Code:<br /> <label> <input name="Post Code" type="text" size="20" maxlength="6" /> </label> <br /> Country:<br /> <label> <input name="Country" type="text" size="20" /> </label> <p><u>Package Information<br /> <br /> </u>Webspace:<br /> <label> <input name="Webspace" type="text" size="15" /> </label> MB<br /> Transfer:<br /> <input name="Transfer" type="text" size="15" /> MB<br /> E-Mail Boxes:<br /> <input name="E-Mail Boxes" type="text" size="15" /> <br /> Sub-Domains:<br /> <input name="Sub-Domains" type="text" size="15" /> <br /> SQL Databases:<br /> <input name="SQL Databases" type="text" size="15" /> <br /> FTP Accounts:<br /> <input name="FTP Accounts" type="text" size="15" /> </p> <p> <label> <input type="submit" name="Submit" value="Submit" /> </label> </p> </form> <p> </p> </body> </html> Can anyone tell me where to go from here? Thankyou Tom Bullock Quote Link to comment https://forums.phpfreaks.com/topic/89193-php-contact-form/ Share on other sites More sharing options...
haku Posted February 3, 2008 Share Posted February 3, 2008 You need to learn how to code XHTML properly. Here are a few of the problems with your code as it is: 1) Forms can't have a 'name' attribute. Its been deprecated. 2) <u> cannot be used in xhtml 3) You have your <input> tags inside a label. You should have an opening <label> tag and a closing <label> tag with the label text in between them. The opening tag should have the attribute for="____" included in it. This input name should be the ID for the input tag. 4) you have your <input> tags embedded inside your <label> tags. Take those out. You should clean up those problems first. Next, you need to validate each of the items in the form. You have to figure out what fields must be filled out, and then what kind of data should be in those fields. Then you should perform checks to make sure that these conditions are being met. If they are, then the form information should be processed accordingly, and if they aren't, error messages should be outputted, and the user should see the form again. Quote Link to comment https://forums.phpfreaks.com/topic/89193-php-contact-form/#findComment-456725 Share on other sites More sharing options...
corillo181 Posted February 3, 2008 Share Posted February 3, 2008 well no one will help you if you don't get something stared so put your results into $_POST and come back. Quote Link to comment https://forums.phpfreaks.com/topic/89193-php-contact-form/#findComment-456727 Share on other sites More sharing options...
jshpik1 Posted February 3, 2008 Share Posted February 3, 2008 How I do is with a form that posts to an external file, then the file routes you to different files depending on whether it was a successful submission. Here's my form code. Put something like this on your form page, looks like you have it up there. Your action should be the other file example: action="feedback.php" <form name="form" method="post" action="feedback.php"> <p class="bodymd">Your Name<br> <input type="text" name="name"> </p> <p class="bodymd">Your Bands Name<br> <input type="text" name="bname"> </p> <p class="bodymd">Your Email (for us to get back to you)<br> <input type="text" name="email"> </p> <p class="bodymd">Additional Stuff To Add?<br> <textarea name="comments" rows="5" cols="40"></textarea> </p> <p class="bodymd"> <input type="submit" name="Submit" value="Submit" class="mainoption"> <input type="reset" name="Reset" value="Clear Form" class="liteoption"> </p> </form> Now the external file: <?php // ------------- CONFIGURABLE SECTION ------------------------ // $mailto - set to the email address you want the form // sent to, eg //$mailto = "youremailaddress@example.com" ; $mailto = 'admin@metalhead.tc' ; // $subject - set to the Subject line of the email, eg //$subject = "Feedback Form" ; $subject = "Band Forum Request" ; // the pages to be displayed, eg //$formurl = "http://www.example.com/feedback.html" ; //$errorurl = "http://www.example.com/error.html" ; //$thankyouurl = "http://www.example.com/thankyou.html" ; $formurl = "http://www.metalhead.tc/heavy-metal-bands-forum.php" ; $errorurl = "http://www.metalhead.tc/contact-error.php" ; $thankyouurl = "http://www.metalhead.tc/contact-thanks.php" ; $uself = 0; // -------------------- END OF CONFIGURABLE SECTION --------------- $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ; $name = $_POST['name'] ; $bname = $_POST['bname'] ; $email = $_POST['email'] ; $comments = $_POST['comments'] ; $http_referrer = getenv( "HTTP_REFERER" ); if (!isset($_POST['email'])) { header( "Location: $formurl" ); exit ; } // if certain fields are empty, give error page if (empty($name) || empty($email) || empty($bname)) { header( "Location: $errorurl" ); exit ; } if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) { header( "Location: $errorurl" ); exit ; } if (get_magic_quotes_gpc()) { $comments = stripslashes( $comments ); } // composing the message to be sent to you $messageproper = "This message was sent from:\n" . "$http_referrer\n" . "------------------------------------------------------------\n" . "Your Name: $name\n" . "Bands Name: $bname\n" . "Email: $email\n" . "------------------------- COMMENTS -------------------------\n\n" . $comments . "\n\n------------------------------------------------------------\n" ; mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.08" ); header( "Location: $thankyouurl" ); exit ; ?> You'll have to add variables to your feedback file depending on the fields in your form. Make sure your form is right first... Quote Link to comment https://forums.phpfreaks.com/topic/89193-php-contact-form/#findComment-456733 Share on other sites More sharing options...
TomBullock Posted February 3, 2008 Author Share Posted February 3, 2008 How I do is with a form that posts to an external file, then the file routes you to different files depending on whether it was a successful submission. Here's my form code. Put something like this on your form page, looks like you have it up there. Your action should be the other file example: action="feedback.php" <form name="form" method="post" action="feedback.php"> <p class="bodymd">Your Name<br> <input type="text" name="name"> </p> <p class="bodymd">Your Bands Name<br> <input type="text" name="bname"> </p> <p class="bodymd">Your Email (for us to get back to you)<br> <input type="text" name="email"> </p> <p class="bodymd">Additional Stuff To Add?<br> <textarea name="comments" rows="5" cols="40"></textarea> </p> <p class="bodymd"> <input type="submit" name="Submit" value="Submit" class="mainoption"> <input type="reset" name="Reset" value="Clear Form" class="liteoption"> </p> </form> Now the external file: <?php // ------------- CONFIGURABLE SECTION ------------------------ // $mailto - set to the email address you want the form // sent to, eg //$mailto = "youremailaddress@example.com" ; $mailto = 'admin@metalhead.tc' ; // $subject - set to the Subject line of the email, eg //$subject = "Feedback Form" ; $subject = "Band Forum Request" ; // the pages to be displayed, eg //$formurl = "http://www.example.com/feedback.html" ; //$errorurl = "http://www.example.com/error.html" ; //$thankyouurl = "http://www.example.com/thankyou.html" ; $formurl = "http://www.metalhead.tc/heavy-metal-bands-forum.php" ; $errorurl = "http://www.metalhead.tc/contact-error.php" ; $thankyouurl = "http://www.metalhead.tc/contact-thanks.php" ; $uself = 0; // -------------------- END OF CONFIGURABLE SECTION --------------- $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ; $name = $_POST['name'] ; $bname = $_POST['bname'] ; $email = $_POST['email'] ; $comments = $_POST['comments'] ; $http_referrer = getenv( "HTTP_REFERER" ); if (!isset($_POST['email'])) { header( "Location: $formurl" ); exit ; } if (empty($name) || empty($email) || empty($bname)) { header( "Location: $errorurl" ); exit ; } if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) { header( "Location: $errorurl" ); exit ; } if (get_magic_quotes_gpc()) { $comments = stripslashes( $comments ); } // composing the message to be sent to you $messageproper = "This message was sent from:\n" . "$http_referrer\n" . "------------------------------------------------------------\n" . "Your Name: $name\n" . "Bands Name: $bname\n" . "Email: $email\n" . "------------------------- COMMENTS -------------------------\n\n" . $comments . "\n\n------------------------------------------------------------\n" ; mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.08" ); header( "Location: $thankyouurl" ); exit ; ?> You'll have to add variables to your feedback file depending on the fields in your form. Make sure your form is right first... If i used this and added my fields to the form, would i have to add more script into the php script? Quote Link to comment https://forums.phpfreaks.com/topic/89193-php-contact-form/#findComment-456734 Share on other sites More sharing options...
jshpik1 Posted February 3, 2008 Share Posted February 3, 2008 You would just have to change the names on the form to correspond to yours, and then change the variables on the external file. You would also have to change the variables that would route them to the error page corresponding to the ones you want. Quote Link to comment https://forums.phpfreaks.com/topic/89193-php-contact-form/#findComment-456746 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.