NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page PHP Form Submit Code...

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 06-09-2005, 12:19 PM THREAD STARTER               #1 (permalink)
New Member
Join Date: Jun 2005
Posts: 10
Zoosushi is an unknown quantity at this point
 



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
Zoosushi is offline  
Old 06-09-2005, 01:39 PM   #2 (permalink)
Senior Member
 
Porte's Avatar
Join Date: May 2005
Location: I'm right here
Posts: 3,526
Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of
 



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
Porte is offline  
Old 06-09-2005, 02:50 PM THREAD STARTER               #3 (permalink)
New Member
Join Date: Jun 2005
Posts: 10
Zoosushi is an unknown quantity at this point
 



Worked Like A Champ. Thank you so much!
Zoosushi is offline  
Old 06-09-2005, 03:25 PM   #4 (permalink)
Senior Member
 
Porte's Avatar
Join Date: May 2005
Location: I'm right here
Posts: 3,526
Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of
 



You're welcome, get back if you have more questions.
__________________
WP Theme Developer
Your One-stop for Premium Magazine/CMS WordPress Themes
Deluxe Themes
Porte is offline  
Old 06-13-2005, 02:46 AM   #5 (permalink)
New Member
Join Date: Jun 2005
Location: Townsville/Australia
Posts: 3
sonicfeaver is an unknown quantity at this point
 



You could try my formail script? also in php script
Attached Files
File Type: txt sendmail script.txt (235 Bytes, 2 views)
sonicfeaver is offline  
Closed Thread


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

Liquid Web Smart Servers  
All times are GMT -7. The time now is 04:06 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger