Dynadot โ€” .com Transfer

PHP Form Submit Code...

SpaceshipSpaceship
Watch

Zoosushi

Established Member
Impact
0
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 = "[email protected]"; // 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);
$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 ="[email protected]"; }
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="[email protected]"><input type="hidden" name="redirect" value="http://www.MYDOMAIN.COM/thankyou.htm">



-----

Any help you anyone could provide would be greatly appreciated. Thank you :)
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
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.
 
0
•••
Worked Like A Champ. Thank you so much!
 
0
•••
You're welcome, get back if you have more questions.
 
0
•••
You could try my formail script? also in php script
 
0
•••
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back