ctcp Posted March 18, 2011 Share Posted March 18, 2011 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <?php include_once 'common.php'; require_once("pages/validation.php"); ?> <? if (!$_COOKIE["ln"]){ $data['lang_ch']=$data['DefaultLanguage']; setcookie("ln", $data['lang_ch']); } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title></title> <meta name="keywords" content="" /> <meta name="description" content="" /> <link href="css/1.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="header"> <!-- This is where the image of the house goes --> </div> <h1 class="main_title"><a href="#"></a></h1> <? include ('pages/menu.php') ?> <div id="container"> <div id="inner_container"> <div id="content"> <?if( isset($_POST['send']) && (!validateName($_POST['name']) || !validateEmail($_POST['email']) || !validateMessage($_POST['message']) ) ):?> <div id="error"> <ul> <?if(!validateName($_POST['name'])):?> <li><strong><?= $errorname?></strong> <?= $errorname1?></li> <?endif?> <?if(!validateEmail($_POST['email'])):?> <li><strong><?=$errormail?></strong> <?=$errormail1?></li> <?endif?> <?if(!validateMessage($_POST['message'])):?> <li><strong><?=$errormessage?></strong> <?=$errormessage?></li> <?endif?> </ul> </div> <?elseif(isset($_POST['send'])):?> <div id="error" class="valid"> <ul> <li><strong><?=$congratulations?></strong> <?=$congratulations?></li> </ul> </div> <?endif?> <form method="post" id="customForm" action=""> <div> <label for="name"><?= $name; ?></label> <input id="name" name="name" type="text" /> <span id="nameInfo"><?= $yourname; ?></span> </div> <div> <label for="email"><?= $email; ?></label> <input id="email" name="email" type="text" /> <span id="emailInfo"><?= $yourmail; ?></span> </div> <div> <label for="pass1"><?= $group; ?></label> <input id="pass1" name="pass1" type="text" /> <span id="pass1Info"><?= $yourgroup; ?></span> </div> <div> <label for="pass2"><?= $countrys; ?></label> <select name="country"> <option value="AF">Afghanistan</option> <option value="AX">ÅLand Islands</option> </select> </div> <div> <label for="message"><?=$message?></label> <textarea id="message" name="message" cols="" rows=""></textarea> </div> <div> <input id="send" name="send" type="submit" value="<?=$submit;?>" /> </div> </form> </div> <script type="text/javascript" src="ajax/jquery.js"></script> <script type="text/javascript" src="ajax/validation.js"></script> </body> </html> </div> </div> </div> <div id="footer"> </body> </html> if all fields is ok how to go to insert.php? can sombady help me please .. Quote Link to comment https://forums.phpfreaks.com/topic/230995-how-to-after-submit-got-to-insertphp/ Share on other sites More sharing options...
gristoi Posted March 18, 2011 Share Posted March 18, 2011 you need to set the action of your form, to tell it where to post the data to <form method="post" id="customForm" action="insert.php"> Quote Link to comment https://forums.phpfreaks.com/topic/230995-how-to-after-submit-got-to-insertphp/#findComment-1189073 Share on other sites More sharing options...
ctcp Posted March 18, 2011 Author Share Posted March 18, 2011 you need to set the action of your form, to tell it where to post the data to <form method="post" id="customForm" action="insert.php"> yes but i whant first check the fields if is ok email and username Quote Link to comment https://forums.phpfreaks.com/topic/230995-how-to-after-submit-got-to-insertphp/#findComment-1189086 Share on other sites More sharing options...
gristoi Posted March 18, 2011 Share Posted March 18, 2011 Can you show the ajax/validation.js file Quote Link to comment https://forums.phpfreaks.com/topic/230995-how-to-after-submit-got-to-insertphp/#findComment-1189091 Share on other sites More sharing options...
ctcp Posted March 18, 2011 Author Share Posted March 18, 2011 Can you show the ajax/validation.js file /***************************/ //@Author: Adrian "yEnS" Mato Gondelle & Ivan Guardado Castro //@website: www.yensdesign.com //@email: [email protected] //@license: Feel free to use it, but keep this credits please! /***************************/ $(document).ready(function(){ //global vars var form = $("#customForm"); var name = $("#name"); var nameInfo = $("#nameInfo"); var email = $("#email"); var emailInfo = $("#emailInfo"); //var pass1 = $("#pass1"); //var pass1Info = $("#pass1Info"); //var pass2 = $("#pass2"); //var pass2Info = $("#pass2Info"); var message = $("#message"); //On blur name.blur(validateName); email.blur(validateEmail); pass1.blur(validatePass1); pass2.blur(validatePass2); //On key press name.keyup(validateName); //pass1.keyup(validatePass1); //pass2.keyup(validatePass2); //message.keyup(validateMessage); //On Submitting form.submit(function(){ if(validateName() & validateEmail() & validateMessage()) return true else return false; }); //validation functions function validateEmail(){ //testing regular expression var a = $("#email").val(); var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/; //if it's valid email if(filter.test(a)){ email.removeClass("error"); emailInfo.text("Valid E-mail please"); emailInfo.removeClass("error"); return true; } //if it's NOT valid else{ email.addClass("error"); emailInfo.text("Type a valid e-mail please "); emailInfo.addClass("error"); return false; } } function validateName(){ //if it's NOT valid if(name.val().length < 4){ name.addClass("error"); nameInfo.text("We want names with more than 3 letters!"); nameInfo.addClass("error"); return false; } //if it's valid else{ name.removeClass("error"); nameInfo.text("What's your name?"); nameInfo.removeClass("error"); return true; } } //function validatePass1(){ //var a = $("#password1"); //var b = $("#password2"); //it's NOT valid //if(pass1.val().length <5){ // pass1.addClass("error"); // pass1Info.text("Ey! Remember: At least 5 characters: letters, numbers and '_'"); // pass1Info.addClass("error"); // return false; // } //it's valid // else{ // pass1.removeClass("error"); // pass1Info.text("At least 5 characters: letters, numbers and '_'"); // pass1Info.removeClass("error"); // validatePass2(); // return true; // } //} //function validatePass2(){ // var a = $("#password1"); // var b = $("#password2"); //are NOT valid // if( pass1.val() != pass2.val() ){ // pass2.addClass("error"); // pass2Info.text("Passwords doesn't match!"); // pass2Info.addClass("error"); // return false; // } //are valid //else{ //pass2.removeClass("error"); // pass2Info.text("Confirm password"); // pass2Info.removeClass("error"); // return true; // } //} function validateMessage(){ //it's NOT valid if(message.val().length < 10){ message.addClass("error"); return false; } //it's valid else{ message.removeClass("error"); return true; } } }); thank you for your time Quote Link to comment https://forums.phpfreaks.com/topic/230995-how-to-after-submit-got-to-insertphp/#findComment-1189094 Share on other sites More sharing options...
gristoi Posted March 18, 2011 Share Posted March 18, 2011 I am afraid I am not completely understanding what you need to do. If you just need to redirect after the fields are valid then you could use <?elseif(isset($_POST['send'])):?> header('Location:insert.php'); <?endif?> Quote Link to comment https://forums.phpfreaks.com/topic/230995-how-to-after-submit-got-to-insertphp/#findComment-1189098 Share on other sites More sharing options...
ctcp Posted March 18, 2011 Author Share Posted March 18, 2011 I am afraid I am not completely understanding what you need to do. If you just need to redirect after the fields are valid then you could use <?elseif(isset($_POST['send'])):?> header('Location:insert.php'); <?endif?> no work but anyway thank you mate Quote Link to comment https://forums.phpfreaks.com/topic/230995-how-to-after-submit-got-to-insertphp/#findComment-1189105 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.