...

View Full Version : PHP and web forms



levani
03-11-2009, 08:51 PM
Hello

I have one specific problem and need your help very much. I have a wordpress blog with custom write panel and my site users can write posts without admin panel. There is one list form for choosing category. This is the main source of problems :)

When I choose a category the form works fine and adds the post in selected category, but when I don't choose anything at all it still adds the post in first category from the list and I want to prevent this.

This is the submit button code of my form:

<input type="submit" value="შეკითხვის დამატება" name="tdomf_form13_send" id="tdomf_form13_send" onclick="tdomfSubmit13('post'); return false;" />

As you can see it uses some tdomfSubmit13 function and in my opinion it causes the strange behaviour of the form.

Here is what this function does.

This:


// Form buttons
//
if($hack) {
$form .= "\t<!-- form buttons start -->\n";
}
$form .= "\t<table class='tdomf_buttons'><tr>\n";
if(tdomf_widget_is_preview_avaliable($form_id)) {
$form .= "\t\t".'<td><input type="submit" value="'.__("Preview","tdomf").'" name="tdomf_form'.$form_id.'_preview" id="tdomf_form'.$form_id.'_preview" onclick="tdomfSubmit'.$form_id."('preview'); return false;\" /></td>\n";
}
$form .= "\t\t".'<td><input type="submit" value="'.__("Send","tdomf").'" name="tdomf_form'.$form_id.'_send" id="tdomf_form'.$form_id.'_send" onclick="tdomfSubmit'.$form_id."('post'); return false;\" /></td>\n";
$form .= "\t</tr></table>\n";
if($hack) {
$form .= "\t<!-- form buttons end -->\n";
}

$form .= "</form>\n";

if($hack) {
$form .= "<!-- form end -->\n<!-- Form $form_id end -->\n";
}

return $form;
}


And this:


function tdomfSubmit$form_id(action) {
ajaxProgressStart$form_id();
var mysack = new sack("$ajax_script" );
mysack.execute = 1;
mysack.method = 'POST';
mysack.setVar( "tdomf_action", action );
mysack.setVar( "tdomf_args", jQuery('#$form_name').serialize());
mysack.onError = function() { alert('$ajax_error' )};
mysack.runAJAX();
return true;
}

If you can guess what's wrong please let me know

Thanks

ohgod
03-12-2009, 03:01 PM
When I choose a category the form works fine and adds the post in selected category, but when I don't choose anything at all it still adds the post in first category from the list and I want to prevent this.

you don't say how the category is chosen... but if it is select or radio whatever then make a default option with a null value and then either validate with js prior to submission or have your php check to make sure category isn't null before processing.

levani
03-12-2009, 06:54 PM
you don't say how the category is chosen...
It's a list form...


but if it is select or radio whatever then make a default option with a null value and then either validate with js prior to submission or have your php check to make sure category isn't null before processing.
I'm sorry I'm not capable of it :( could you please provide some example of code, if it's not very difficult?

Thanks

ohgod
03-12-2009, 07:55 PM
if by list you mean select... then here is a rough example. make sure you use all your details and proper form info



<form onSubmit="validate();" name="yourform" id="yourform">
<select name="yourlist" id="yourlist">
<option value="">Select one...</option>
<option value="category1">Category1</option>
</select>
<input type="submit" value="Submit" />
</form>


would call:


<script type="text/javascript">
function validate(){
var sel = yourform.yourlist.options[yourform.yourlist.selectedIndex].value;
if(sel == ""){
alert('Please select a category!');
return false;
}else{
document.yourform.submit();
}

}
</script>

levani
03-12-2009, 08:13 PM
if by list you mean select... then here is a rough example. make sure you use all your details and proper form info



<form onSubmit="validate();" name="yourform" id="yourform">
<select name="yourlist" id="yourlist">
<option value="">Select one...</option>
<option value="category1">Category1</option>
</select>
<input type="submit" value="Submit" />
</form>


would call:


<script type="text/javascript">
function validate(){
var sel = yourform.yourlist.options[yourform.yourlist.selectedIndex].value;
if(sel == ""){
alert('Please select a category!');
return false;
}else{
document.yourform.submit();
}

}
</script>


It's doesn't work. I have already tried to use something similar to this it's no use.

I think somehow it gets some information tdomfSubmit13 function and adds the post in default category automatically whether the category is choosen or not.

welchyboy
03-19-2009, 06:54 AM
Hello everyone I could use some help. I have a form which I have on a site to you can see and I like it very much. However the validation I have I don't really like. I have it setup to check if certain fields are blank and if I hit submit it will check the first field to see if it is blank if it is it will take me to an error page. However if it is not it will go to the next field and check. However what I would like is it to check the whole form and display all the errors at once. I would also prefer to have the errors displayed on the page without having to refresh. I have spent many hours on this and just trying to perfect it. The way I have it set up it works and even sends the email just the way I like I just need some help with the validation. Please if anyone can help I would be extremely thankful. Here is some detailed information about what I am working with...I would also like to be able to have the sender be the name that is entered by the user. I have tried changing the headers and so forth but doesn't seem to work.

My PHP looks like this




<?

$Name = $_POST["Name"];

$Address = $_POST["Address"];
$Address2 = $_POST["Address2"];
$City = $_POST["City"];
$State = $_POST["State"];
$Country = $_POST["Country"];
$Zip = $_POST["Zip"];
$Phone = $_POST["Phone"];
$Email = $_POST["Email"];




$today = date("M d, Y");
$recipient = "you@yourdomain.com";
$subject = "TEST SUBJECt";
$headers = 'From: <webmaster@example.com>' . "\r\n";
$forminfo =
"Name: $Name\n
Address: $Address\n
Address2: $Address2\n
City: $City\n
State: $State\n
Country: $Country\n
Zip: $Zip\n
Phone: $Phone\n
Email: $Email\n


Form Submitted: $today\n\n";



if (!empty($_POST['Name'])){
$msg = "";
}else{
$Name = NULL;
echo "Please fill out your first name.<br />";
echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">";
exit;
}


if (!empty($_POST['Address'])){
$msg = "";
}else{
$Name = NULL;
echo "Please fill out your Street Name.<br />";
echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">";
exit;
}



if (!empty($_POST['City'])){
$msg = "";
}else{
$Name = NULL;
echo "Please fill out your City.<br />";
echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">";
exit;
}



if (!empty($_POST['State'])){
$msg = "";
}else{
$Name = NULL;
echo "Please fill out your State.<br />";
echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">";
exit;
}


if (!empty($_POST['Country'])){
$msg = "";
}else{
$Name = NULL;
echo "Please fill out your Country.<br />";
echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">";
exit;
}





/* if (!empty($_POST['LastName'])){
$msg = "";
}else{
$LastName = NULL;
echo "Please fill out your Last name.<br />";
echo "<meta http-equiv=\"refresh\" content=\"2;URL=form.html\">";
exit;
} */






if (preg_match ("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn |bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk| dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs |gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr| kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum |mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr |pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf |tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za| zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $Email)) {
mail($toaddress,$subject,$headers,$message);
//clear the variables
$Name='';
$Email='';






echo "";
} else {
echo nl2br ("Please enter correct email.\n");
echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">";
exit;
}










$formsend = mail("$recipient", "$subject", "$forminfo", "From: $email\r\nReply-to:$email");
?>
<!-- end PHP easy-form -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Make a Donation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="refresh" content="5; URL=index.php?main_page=contact_us_1">
<style type="text/css">
<!--
.style1 {
font-size: 24px;
font-weight: bold;
}
body {
background-color: #ade4b0;
}
-->
</style>
</head>







<body>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td> <p align="left" class="style1">Thank you. You submission has been complete.Redirecting...</p>
</tr>
</table>
</td>
</body>
</html>





My HTML looks like this





<!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=UTF-8">
<title>Untitled Form</title>
<link rel="stylesheet" type="text/css" href="view.css" media="all">
<script type="text/javascript" src="view.js"></script>







</head>
<body id="main_body" >

<br />
<br />

<div id="form_container">


<form id="form_14512" class="appnitro" method="post" action="myform.php">


<div class="form_description">
<h2>Request A Brochure</h2>
</div>
<ul >

<li id="li_1" >
<label class="description" for="Name">* Name </label>
<div>
<input id="Name" name="Name" class="element text medium" type="text" maxlength="255" value=""/>
</div><p class="guidelines" id="guide_1"><small>Enter your name</small></p>
</li> <li id="li_2" >
<label class="description" for="element_2">* Mailing Address </label>

<div><strong>
<input id="Address" name="Address" class="element text large" value="" type="text">
<label for="Address">* Street Address</label>
</strong></div>

<div>
<input id="Address2" name="Address2" class="element text large" value="" type="text">
<label for="Address2">Address Line 2</label>
</div>

<div class="left"><strong>
<input id="City" name="City" class="element text medium" value="" type="text">
<label for="City">* City</label>
</strong></div>

<div class="right"><strong>
<input id="State" name="State" class="element text medium" value="" type="text">
<label for="State">* State / Province / Region</label>
</strong></div>

<div class="left"><strong>
<input id="Zip" name="Zip" class="element text medium" maxlength="15" value="" type="text">
<label for="Zip">* Postal / Zip Code</label>
</strong></div>

<div class="right"><strong>
<select class="element select medium" id="Country" name="Country">
<option value="" selected="selected"></option>
<option value="Afghanistan" >Afghanistan</option>
<option value="Albania" >Albania</option>
<option value="Algeria" >Algeria</option>
<option value="Andorra" >Andorra</option>
<option value="Antigua and Barbuda" >Antigua and Barbuda</option>
<option value="Argentina" >Argentina</option>
<option value="Armenia" >Armenia</option>
<option value="Australia" >Australia</option>
<option value="Austria" >Austria</option>
<option value="Azerbaijan" >Azerbaijan</option>
<option value="Bahamas" >Bahamas</option>
<option value="Bahrain" >Bahrain</option>
<option value="Bangladesh" >Bangladesh</option>
<option value="Barbados" >Barbados</option>
<option value="Belarus" >Belarus</option>
<option value="Belgium" >Belgium</option>
<option value="Belize" >Belize</option>
<option value="Benin" >Benin</option>
<option value="Bhutan" >Bhutan</option>
<option value="Bolivia" >Bolivia</option>
<option value="Bosnia and Herzegovina" >Bosnia and Herzegovina</option>
<option value="Botswana" >Botswana</option>
<option value="Brazil" >Brazil</option>
<option value="Brunei" >Brunei</option>
<option value="Bulgaria" >Bulgaria</option>
<option value="Burkina Faso" >Burkina Faso</option>
<option value="Burundi" >Burundi</option>
<option value="Cambodia" >Cambodia</option>
<option value="Cameroon" >Cameroon</option>
<option value="Canada" >Canada</option>
<option value="Cape Verde" >Cape Verde</option>
<option value="Central African Republic" >Central African Republic</option>
<option value="Chad" >Chad</option>
<option value="Chile" >Chile</option>
<option value="China" >China</option>
<option value="Colombia" >Colombia</option>
<option value="Comoros" >Comoros</option>
<option value="Congo" >Congo</option>
<option value="Costa Rica" >Costa Rica</option>
<option value="Côte d'Ivoire" >Côte d'Ivoire</option>
<option value="Croatia" >Croatia</option>
<option value="Cuba" >Cuba</option>
<option value="Cyprus" >Cyprus</option>
<option value="Czech Republic" >Czech Republic</option>
<option value="Denmark" >Denmark</option>
<option value="Djibouti" >Djibouti</option>
<option value="Dominica" >Dominica</option>
<option value="Dominican Republic" >Dominican Republic</option>
<option value="East Timor" >East Timor</option>
<option value="Ecuador" >Ecuador</option>
<option value="Egypt" >Egypt</option>
<option value="El Salvador" >El Salvador</option>
<option value="Equatorial Guinea" >Equatorial Guinea</option>
<option value="Eritrea" >Eritrea</option>
<option value="Estonia" >Estonia</option>
<option value="Ethiopia" >Ethiopia</option>
<option value="Fiji" >Fiji</option>
<option value="Finland" >Finland</option>
<option value="France" >France</option>
<option value="Gabon" >Gabon</option>
<option value="Gambia" >Gambia</option>
<option value="Georgia" >Georgia</option>
<option value="Germany" >Germany</option>
<option value="Ghana" >Ghana</option>
<option value="Greece" >Greece</option>
<option value="Grenada" >Grenada</option>
<option value="Guatemala" >Guatemala</option>
<option value="Guinea" >Guinea</option>
<option value="Guinea-Bissau" >Guinea-Bissau</option>
<option value="Guyana" >Guyana</option>
<option value="Haiti" >Haiti</option>
<option value="Honduras" >Honduras</option>
<option value="Hong Kong" >Hong Kong</option>
<option value="Hungary" >Hungary</option>
<option value="Iceland" >Iceland</option>
<option value="India" >India</option>
<option value="Indonesia" >Indonesia</option>
<option value="Iran" >Iran</option>
<option value="Iraq" >Iraq</option>
<option value="Ireland" >Ireland</option>
<option value="Israel" >Israel</option>
<option value="Italy" >Italy</option>
<option value="Jamaica" >Jamaica</option>
<option value="Japan" >Japan</option>
<option value="Jordan" >Jordan</option>
<option value="Kazakhstan" >Kazakhstan</option>
<option value="Kenya" >Kenya</option>
<option value="Kiribati" >Kiribati</option>
<option value="North Korea" >North Korea</option>
<option value="South Korea" >South Korea</option>
<option value="Kuwait" >Kuwait</option>
<option value="Kyrgyzstan" >Kyrgyzstan</option>
<option value="Laos" >Laos</option>
<option value="Latvia" >Latvia</option>
<option value="Lebanon" >Lebanon</option>
<option value="Lesotho" >Lesotho</option>
<option value="Liberia" >Liberia</option>
<option value="Libya" >Libya</option>
<option value="Liechtenstein" >Liechtenstein</option>
<option value="Lithuania" >Lithuania</option>
<option value="Luxembourg" >Luxembourg</option>
<option value="Macedonia" >Macedonia</option>
<option value="Madagascar" >Madagascar</option>
<option value="Malawi" >Malawi</option>
<option value="Malaysia" >Malaysia</option>
<option value="Maldives" >Maldives</option>
<option value="Mali" >Mali</option>
<option value="Malta" >Malta</option>
<option value="Marshall Islands" >Marshall Islands</option>
<option value="Mauritania" >Mauritania</option>
<option value="Mauritius" >Mauritius</option>
<option value="Mexico" >Mexico</option>
<option value="Micronesia" >Micronesia</option>
<option value="Moldova" >Moldova</option>
<option value="Monaco" >Monaco</option>
<option value="Mongolia" >Mongolia</option>
<option value="Montenegro" >Montenegro</option>
<option value="Morocco" >Morocco</option>
<option value="Mozambique" >Mozambique</option>
<option value="Myanmar" >Myanmar</option>
<option value="Namibia" >Namibia</option>
<option value="Nauru" >Nauru</option>
<option value="Nepal" >Nepal</option>
<option value="Netherlands" >Netherlands</option>
<option value="New Zealand" >New Zealand</option>
<option value="Nicaragua" >Nicaragua</option>
<option value="Niger" >Niger</option>
<option value="Nigeria" >Nigeria</option>
<option value="Norway" >Norway</option>
<option value="Oman" >Oman</option>
<option value="Pakistan" >Pakistan</option>
<option value="Palau" >Palau</option>
<option value="Panama" >Panama</option>
<option value="Papua New Guinea" >Papua New Guinea</option>
<option value="Paraguay" >Paraguay</option>
<option value="Peru" >Peru</option>
<option value="Philippines" >Philippines</option>
<option value="Poland" >Poland</option>
<option value="Portugal" >Portugal</option>
<option value="Puerto Rico" >Puerto Rico</option>
<option value="Qatar" >Qatar</option>
<option value="Romania" >Romania</option>
<option value="Russia" >Russia</option>
<option value="Rwanda" >Rwanda</option>
<option value="Saint Kitts and Nevis" >Saint Kitts and Nevis</option>
<option value="Saint Lucia" >Saint Lucia</option>
<option value="Saint Vincent and the Grenadines" >Saint Vincent and the Grenadines</option>
<option value="Samoa" >Samoa</option>
<option value="San Marino" >San Marino</option>
<option value="Sao Tome and Principe" >Sao Tome and Principe</option>
<option value="Saudi Arabia" >Saudi Arabia</option>
<option value="Senegal" >Senegal</option>
<option value="Serbia and Montenegro" >Serbia and Montenegro</option>
<option value="Seychelles" >Seychelles</option>
<option value="Sierra Leone" >Sierra Leone</option>
<option value="Singapore" >Singapore</option>
<option value="Slovakia" >Slovakia</option>
<option value="Slovenia" >Slovenia</option>
<option value="Solomon Islands" >Solomon Islands</option>
<option value="Somalia" >Somalia</option>
<option value="South Africa" >South Africa</option>
<option value="Spain" >Spain</option>
<option value="Sri Lanka" >Sri Lanka</option>
<option value="Sudan" >Sudan</option>
<option value="Suriname" >Suriname</option>
<option value="Swaziland" >Swaziland</option>
<option value="Sweden" >Sweden</option>
<option value="Switzerland" >Switzerland</option>
<option value="Syria" >Syria</option>
<option value="Taiwan" >Taiwan</option>
<option value="Tajikistan" >Tajikistan</option>
<option value="Tanzania" >Tanzania</option>
<option value="Thailand" >Thailand</option>
<option value="Togo" >Togo</option>
<option value="Tonga" >Tonga</option>
<option value="Trinidad and Tobago" >Trinidad and Tobago</option>
<option value="Tunisia" >Tunisia</option>
<option value="Turkey" >Turkey</option>
<option value="Turkmenistan" >Turkmenistan</option>
<option value="Tuvalu" >Tuvalu</option>
<option value="Uganda" >Uganda</option>
<option value="Ukraine" >Ukraine</option>
<option value="United Arab Emirates" >United Arab Emirates</option>
<option value="United Kingdom" >United Kingdom</option>
<option value="United States" >United States</option>
<option value="Uruguay" >Uruguay</option>
<option value="Uzbekistan" >Uzbekistan</option>
<option value="Vanuatu" >Vanuatu</option>
<option value="Vatican City" >Vatican City</option>
<option value="Venezuela" >Venezuela</option>
<option value="Vietnam" >Vietnam</option>
<option value="Yemen" >Yemen</option>
<option value="Zambia" >Zambia</option>
<option value="Zimbabwe" >Zimbabwe</option>
</select>
<label for="Country">* Country</label>
</strong></div>
<p class="guidelines" id="guide_2"><small>Enter your mailing address</small></p>
</li> <li id="li_3" >
<label class="description" for="Phone">Phone Number </label>
<div>
<input id="Phone" name="Phone" class="element text medium" type="text" maxlength="255" value=""/>
</div><p class="guidelines" id="guide_3"><small>Enter your phone number</small></p>
</li> <li id="li_4" >
<label class="description" for="Email">* Email </label>
<div>
<input id="Email" name="Email" class="element text medium" type="text" maxlength="255" value=""/>
</div><p class="guidelines" id="guide_4"><small>Enter your email address</small></p>
</li>

<li class="buttons">
<input type="hidden" name="form_id" value="14512" />

<input value="Submit form" type="submit" />
</li>
</ul>
</form>
<div id="footer"></div>
</div>
</body>
</html>





You can see the form in working order on the site located here


http://www.+stxm+illing.com+/index.+php?main_+page=conta+ct_us_1


PLEASE TAKE THE '+' OUT OF THE URL IN ORDER FOR IT TO WORK.

Any feedback is greatly appreciated!!

welchyboy
03-21-2009, 12:16 AM
Sorry the link did not paste correctly here is the link again

stxm+illing.com/index.php?main_page=cont+act_us_1

Again Please take out the two '+' signs

By the way I have modified the code just a little and I feel I am getting very close.

My php






<?





$Name = $_POST["Name"];

$Address = $_POST["Address"];
$Address2 = $_POST["Address2"];
$City = $_POST["City"];
$State = $_POST["State"];
$Country = $_POST["Country"];
$Zip = $_POST["Zip"];
$Phone = $_POST["Phone"];
$Email = $_POST["Email"];




$today = date("M d, Y");
$recipient = "me@me.com";
$subject = "Request a Brochure";
$headers = 'From: <webmaster@example.com>' . "\r\n";
$forminfo =
"Name: $Name\n
Address: $Address\n
Address2: $Address2\n
City: $City\n
State: $State\n
Country: $Country\n
Zip: $Zip\n
Phone: $Phone\n
Email: $Email\n


Form Submitted: $today\n\n";











if (!empty($_POST['Name'])){
$msg = "Name; $_POST[Name] ";
}else{
$Name = NULL;
echo "Please fill out your first name.<br />";


}


if (!empty($_POST['Address'])){
$msg = "Address; $_POST[Address] ";
}else{
$Address = NULL;
echo "Please fill out your Address.<br />";

}

if (!empty($_POST['City'])){
$msg = "City; $_POST[City] ";
}else{
$City = NULL;
echo "Please fill out your City.<br />";

}


if (!empty($_POST['State'])){
$msg = "State; $_POST[State] ";
}else{
$State = NULL;
echo "Please fill out your State.<br />";

}

if (!empty($_POST['zipcode'])){
$msg = "zipcode; $_POST[zipcode] ";
}else{
$zipcode = NULL;
echo "Please fill out your zipcode.<br />";

}



if (!empty($_POST['Country'])){
$msg = "Country; $_POST[Country] ";
}else{
$Country = NULL;
echo "Please fill out your Country.<br />";

}



/* if (!empty($_POST['Name'])){
$msg = "";
}else{
$Name = NULL;
echo "Please fill out your first name.<br />";
echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">";
exit;
}


if (!empty($_POST['Address'])){
$msg = "";
}else{
$Name = NULL;
echo "Please fill out your Street Name.<br />";
echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">";
exit;
}



if (!empty($_POST['City'])){
$msg = "";
}else{
$Name = NULL;
echo "Please fill out your City.<br />";
echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">";
exit;
}



if (!empty($_POST['State'])){
$msg = "";
}else{
$Name = NULL;
echo "Please fill out your State.<br />";
echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">";
exit;
}


if (!empty($_POST['Country'])){
$msg = "";
}else{
$Name = NULL;
echo "Please fill out your Country.<br />";
echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">";
exit;
}

*/









if (preg_match ("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn |bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk| dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs |gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr| kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum |mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr |pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf |tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za| zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $Email)) {
mail($toaddress,$subject,$headers,$message);
//clear the variables
$Name='';
$Email='';






echo "";
} else {
echo nl2br ("Please enter correct email.\n");
echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">";

}










$formsend = mail("$recipient", "$subject", "$forminfo", "From: $email\r\nReply-to:$email");
?>
<!-- end PHP easy-form -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Make a Donation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="refresh" content="5; URL=index.php?main_page=page_2">
<style type="text/css">
<!--
.style1 {
font-size: 24px;
font-weight: bold;
}
body {
background-color: #ade4b0;
}
-->
</style>
</head>







<body>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td> <p align="left" class="style1">Thank you. You submission has been complete.Redirecting...</p>
</tr>
</table>
</td>
</body>
</html>




I know there is a lot of extra code in here but I have a big portion of the code commented out for testing purposes. But right now I have the code to where it checks the fields and if they are blank it displays an error. However I am not sure how to stop the code because it will display all the errors and still send the email.

If i put a exit; at the end of each if statement it will only display one error at a time. If i put the exit; at the end by the email portion of the script and someone enters their email but nothing else the script will continue and send an email. So I am struggling with some of the code to get it just the way I want. Can anyone help out?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum