| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| New Member Join Date: Jun 2005
Posts: 10
![]() | PHP Form Submit Code... Hey All, I have a question. I am using the below free code to submit forms and i'm having problems trying to get my forms to have "required" input fields and I just can't figure out how to do it. Here is the code that is a .php file that my forms submit using: <?php $MailToAddress = "contact@MYDOMAIN.com"; // your email address $MailSubject = "From Submission From MYDOMAIN.com Website"; // the subject of the message $redirectURL = "http://www.MYDOMAIN.com/thankyou.htm"; // the URL of the thank you page. $errorURL = "http://www.MYDOMAIN.com/error.htm"; // the URL of the error page. # If you are asking for an email address in your form, you can name that input field "email". # If you do this, the message will apear to come from that email address and you can simply click the reply button to answer it. # You can use this scirpt to submit your forms or to receive orders by email. # You need to send the form as POST! # If you have a multiple selection box, or multiple checkboxes, you MUST name the multiple list box or checkbox as "name[]" with "[]" at the end of the name # This script was made by George A. & Calin S. from Web4Future.com # There are no copyrights in the e-mails sent, and we do not ask for anything in return. # DO NOT EDIT BELOW THIS LINE ================================================== ========== # ver. 1.1 if (!is_array($HTTP_POST_VARS)) return; reset($HTTP_POST_VARS); while(list($key, $val) = each($HTTP_POST_VARS)) { $GLOBALS[$key] = $val; if (is_array($val)) { $Message .= "<b>$key:</b> "; foreach ($val as $vala) { $vala =stripslashes($vala); ????: NamePros.com http://www.namepros.com/programming/97181-php-form-submit-code.html $Message .= "$vala, "; } $Message .= "<br>"; } else { $val = stripslashes($val); if (($key == "Submit") || ($key == "submit")) { } else { if ($val == "") { $Message .= "$key: - <br>"; } else { $Message .= "<b>$key:</b> $val<br>"; } } } } // end while if (!$email) { $email ="server@MYDOMAIN.com"; } if (!$Message) { header("Location: ".$errorURL); exit; } else { $Message = "<font face=verdana size=2>".$Message; } mail( $MailToAddress, $MailSubject, $Message, "Content-Type: text/html; charset=ISO-8859-1\r\nFrom: ".$email); header("Location: ".$redirectURL); ?> AND HERE IS THE CODE THAT I NORMALLY USE TO SUBMIT THE FORM: <form method="post" action="script.php"> <input type="hidden" name="recipient" value="info@MYDOMAIN.COM"><input type="hidden" name="redirect" value="http://www.MYDOMAIN.COM/thankyou.htm"> ----- Any help you anyone could provide would be greatly appreciated. Thank you |
| |
| | #2 (permalink) |
| Senior Member Join Date: May 2005 Location: I'm right here
Posts: 3,526
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | You can make this in Javascript, it'll alert the user if any required field is left. or in PHP, in the above code..(I'll consider that all your fields are assigned a name) <input name=''...> You can on top write.. : <? // define required fields $name = $_POST['name']; $email = $_POST['email']; // more fields... if (!$name || !$email) { header("Location: errorpageorsomething.html"); exit(); // won't process any commands under this } Then continue with the typical code.
__________________ WP Theme Developer Your One-stop for Premium Magazine/CMS WordPress Themes Deluxe Themes |
| |
| | #4 (permalink) |
| Senior Member Join Date: May 2005 Location: I'm right here
Posts: 3,526
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | You're welcome, get back if you have more questions.
__________________ WP Theme Developer Your One-stop for Premium Magazine/CMS WordPress Themes Deluxe Themes |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Googlism - What does google think of you? | deadserious | The Break Room | 55 | 12-15-2005 10:09 AM |
| Basic HTML Tutorial | webgear | Webmaster Tutorials | 8 | 04-02-2005 03:20 PM |
| Paypal Settlement | CMachuca | The Break Room | 3 | 07-31-2004 11:14 PM |
| PAYPAL Litigation | johnn | Domain Name Discussion | 6 | 07-31-2004 10:51 PM |
| Paypal Settlement | Lord | The Break Room | 2 | 07-30-2004 10:30 PM |