1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561
| <?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>JQuery Form Wizard</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" ></meta>
<!--link rel="stylesheet" type="text/css" href="css/jquery-ui-1.8.2.custom.css" /-->
<style type="text/css">
body { font-family:Tahoma, Lucida Sans, Arial, Helvetica, Sans-Serif; font-size:15px; margin:20px;}
#demoWrapper {
padding : 1em;
width : 500px;
border-style: solid;
margin : auto;
}
#fieldWrapper {
}
#demoNavigation {
margin-top : 0.5em;
margin-right : 1em;
text-align: right;
}
#data {
font-size : 0.7em;
}
input {
margin-right: 0.1em;
margin-bottom: 0.5em;
font-family : verdan, arial;
font-weight : bold;
color : #1C94C4;
border : 1px solid #CCCCCC;
}
.input_field_25em {
width: 2.5em;
}
.input_field_3em {
width: 3em;
}
.input_field_35em {
width: 3.5em;
}
.input_field_12em {
width: 12em;
}
label {
margin-bottom: 0.2em;
font-weight: bold;
font-size: 0.8em;
}
label span .req {
color: #FF0000;
font-size: 0.8em;
/*margin-left : 0.5em;*/
float : left;
}
label.error {
color: red;
font-size: 0.8em;
margin-left : 0.5em;
}
.step span {
float: right;
font-weight: bold;
padding-right: 0.8em;
}
.navigation_button {
width : 70px;
}
#data {
overflow : auto;
}
#step_visualization {
margin : 2em;
}
#visualization_first{
background-color : #ffffdd;
}
#visualization_second{
background-color : #ffff99;
}
#visualization_confirmation{
background-color : #ffff44;
}
.visualization {
border-style : solid;
font-size: 0.8em;
font-weight: bold;
padding-left: 1em;
padding-right: 1em;
}
.passive {
border-style : solid;
font-size: 0.8em;
color : #eee;
font-weight: bold;
padding-left: 1em;
padding-right: 1em;
}
.active {
border-style : solid;
font-size: 0.8em;
color : #000;
font-weight: bold;
padding-left: 1em;
padding-right: 1em;
}
.font_normal_07em_black {
font-weight : normal;
font-size : 0.7em;
color : black;
}
.button { background-color:#ddd; padding:5px 10px; color:#fff; text-decoration:none; border:0px;}
.button:hover { background-color:#000000; padding:5px 10px; color:#fff; text-decoration:none; border:0px;}
</style>
</head>
<body>
<div id="demoWrapper">
<h3>three steps registration</h3>
<?php
echo "<pre style='margin: 0px 0px 10px 0px; display: block; background: white; color: black; font-family: Verdana; border: 1px solid #cccccc; padding: 5px; font-size: 10px; line-height: 13px;'> POST<br/>";
print_r($_POST);
echo "</pre>";
?>
<hr />
<h5 id="status"></h5>
<form id="demoForm" method="post" action="<?php echo $_SERVER['PHP_SELF']."?do=reg" ;?>" class="bbq">
<div id="fieldWrapper">
<div id="step_visualization"></div>
<span id="step1" class="passive">Step 1</span>
<span id="step2" class="passive">Step 2</span>
<span id="step3" class="passive">Step 3</span>
<?php
if($_GET['do']=="reg"){
if(empty($_SESSION['step'])){
$_SESSION['step']=1;
}
if($_SESSION['step']==1){
if($_POST['refuse']=="refuse"){
echo "<center><h3>you not to approve the conditions of registration <br/> redirecting to the home page <br/></h3></center>";
?>
<script type="text/javascript">
setTimeout("window.location=\"../\";",10000);
</script>
<?php
//}elseif($_POST['ok']!=="1"){
}elseif($_REQUEST['ok']!=="1"){
echo "<center><h3>You do not approve the terms of conditions <br/> redirect you to the previous page<br/></h3></center>";
?>
<script type="text/javascript">
setTimeout("window.location=\"<?php echo $_SERVER['PHP_SELF'];?>\";",10000);
</script>
<?php
}
else{
if(!empty($_POST['step1'])){
//if(!empty($_REQUEST['step1'])){
//insert into table
$_SESSION['step']++;
echo "<center><h3>The registration was successful and process to redirect you to the second phase to complete the basic data<br/></h3></center>";
?>
<script type="text/javascript">
setTimeout("window.location=\"<?php echo $_SERVER['PHP_SELF']."?do=reg";?>\";",10000);
</script>
<?php
}else{
?>
<!-- step 1 -->
<span id="1" class="step">
<span class="font_normal_07em_black">Personal Informations</span><br />
<label for="username"><strong>*</strong>User name</label><br />
<input class="input_field_12em" name="username" id="username" /><br />
<label for="password">*Password</label><br />
<input class="input_field_12em" name="password" id="password" type="password" /><br />
<label for="confirm_password"><strong>*</strong>Retype password</label><br />
<input class="input_field_12em" name="confirm_password" id="confirm_password" type="password" /><br />
<label for="email"><strong>*</strong>Email</label><br />
<input class="input_field_12em" name="email" id="email" /><br />
<label for="code"><span class="req">*</span>Captcha</label><br />
<input class="input_field_12em" name="code" id="code" type="code" /> 89547 <br />
<input type="hidden" name="step1"/>
</span>
<!-- /step 1 -->
<?php
}
}
}elseif($_SESSION['step']==2){
if(!empty($_POST['step2'])){
/*
You enter the data that were added to the base after making sure of their validity and secure
*/
$_SESSION['step']++;
?>
Congratulations you have successfully completed the registration process
<br/>
Being redirected to the login page
<script type="text/javascript">
setTimeout("window.location=\"<?php echo $_SERVER['PHP_SELF']."?do=reg";?>\";",10000);
</script>
<?php
}else{
?>
<!-- step 2 -->
<span id="2" class="step">
<span class="font_normal_07em_black">General informations</span><br />
<label for="newsusername">Username</label><br />
New username <br />
<label for="firstname">First name</label><br />
<input class="input_field_12em" name="firstname" id="firstname" /><br />
<label for="surname">Surname</label><br />
<input class="input_field_12em" name="surname" id="surname" /><br />
<label for="gender">Gender</label><br />
<select id="gender">
<option value="1">Male</option>
<option value="2">Female</option>
</select><br />
<label for="day">Birthday</label><br />
<input class="input_field_25em" name="day" id="day" value="DD" />
<input class="input_field_25em" name="month" id="month" value="MM" />
<input class="input_field_3em" name="year" id="year" value="YYYY" /> -
<!--input class="input_field_3em" name="lastFour" id="lastFour_fi" value="XXXX" /--><br />
<label for="country">Country</label><br />
<select id="country" name="country">
<option>Az</option>
<option>Cd</option>
<option>Qs</option>
<option>Xcc</option>
<option>Pui</option>
</select><br />
<label for="town">Town</label><br />
<input id="town" type="text" /><br />
<label for="zipcode">ZipCode</label><br />
<input id="zipcode" type="text" /><br />
<label for="cat">Category</label><br />
<select id="cat" name="cat">
<option>cat1</option>
<option>cat2</option>
<option>cat3</option>
<option>cat4</option>
</select><br />
<label for="countryPrefix">Phone number</label><br />
<input class="input_field_35em" name="countryPrefix" id="countryPrefix"/> -
<input class="input_field_3em" name="areaCode" id="areaCode" /> -
<input class="input_field_12em" name="phoneNumber" id="phoneNumber" /><br />
<label for="details">Details</label><br />
<p>BBCode</p><br />
<textarea rows="8" name="details" id="details" cols="40">details</textarea>
<p>Smilies</p><br />
<label for="pic">Your Picture</label><br />
<input id="pic" name="pic" type="file" /><br />
</span>
<!-- /step 2 -->
<?php
}
} elseif($_SESSION['step']==3){
echo "<pre style='margin: 0px 0px 10px 0px; display: block; background: white; color: black; font-family: Verdana; border: 1px solid #cccccc; padding: 5px; font-size: 10px; line-height: 13px;'> SESSION<br/>";
print_r($_SESSION);
echo "</pre>";
?>
<!-- step 3 -->
<span id="3" class="step">
<span class="font_normal_07em_black">Congratulation</span><br />
<script type="text/javascript">
setTimeout("window.location='login.php'",10000);
</script>
</span>
<!-- /step 3 -->
<div id="demoNavigation">
<!--input class="navigation_button" id="back" value="Back" type="reset" /-->
<input class="navigation_button" id="next" value="Next" type="submit" />
</div>
<?php
//unset($_SESSION['step']);
}
}else{
unset($_SESSION['step']);
?>
<br />
<!-- terms of conditions -->
<span id="terms" class="step">
<span class="font_normal_07em_black">Terms of conditions</span><br />
<label for="terms">Terms of condition</label><br />
<textarea class="input_field_12em" name="terms" id="terms" />Terms of conditions</textarea>
<br/>
<input id="ok" type="checkbox" name="ok" value="1" /> I agree
<input id="step1" type="hidden" name="step1"/>
<br/><br/>
<!--input id="accept" type="button" value="Accept" name="accept" class="button" /-->
<input id="accept" type="button" value="Accept" name="accept" class="button" />
<input id="refuse" type="button" value="Refuse" name="refuse" class="button" />
</span>
<span id="resp"></span><br />
<span id="verif"></span><br />
<span id="verif2"></span>
<!-- /terms of conditions -->
<?php
}
///
echo "<pre style='margin: 0px 0px 10px 0px; display: block; background: white; color: black; font-family: Verdana; border: 1px solid #cccccc; padding: 5px; font-size: 10px; line-height: 13px;'> SESSION<br/>";
print_r($_SESSION);
echo "</pre>";
///
?>
</div>
</form>
<hr />
<p id="data"></p>
</div>
<script type="text/javascript" src="./js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="./js/jquery.form.js"></script>
<script type="text/javascript" src="./js/jquery.validate.js"></script>
<script type="text/javascript" src="./js/bbq.js"></script>
<script type="text/javascript" src="./js/jquery-ui-1.8.2.custom.min.js"></script>
<script type="text/javascript" src="./js/jquery.form.wizard-3.0.0.js"></script>
<script type="text/javascript" src="./js/jquery.maskedinput.js"></script>
<script type="text/javascript">
$(function(){
$("#accept").click(function(){
var ok = $("input#ok").val();
var step1 = $("input#step1").val();
var formContent = jQuery("#demoForm").serialize();
$("#verif2").html(formContent);
window.location =("register(1).php?do=reg");
return false;
});
$("#refuse").click(function(){
window.location=("index.php");
return false;
});
$.validator.addMethod(
"regex",
function(value, element, regexp) {
if (regexp.constructor != RegExp)
regexp = new RegExp(regexp);
else if (regexp.global)
regexp.lastIndex = 0;
return this.optional(element) || regexp.test(value);
},
"Please check your input.");
jQuery.validator.addMethod("accept", function(value, element, param) {
return value.match(new RegExp("." + param + "$"));
},jQuery.format("Only {0} extentions are allowed"));
// bind a callback to the step_shown event
$("#demoForm").bind("step_shown", function(event, data){
$("#step_visualization").html("");
/*if(data.isBackNavigation || !data.isFirstStep){
var direction = (data.isBackNavigation)?"back":"forward";
$("#step_visualization").append("<div>Moving "+ direction +"</div>");
}*/
$.each(data.activatedSteps, function(i,sval){
$("#step_visualization").append("<span class=\"visualization\" id=\"visualization_" + this + "\">" + i + "</span> ")
switch (i){
case 0 :
/*$('span#step1').removeClass().addClass('active');*/
$('span#step3').removeClass('active').addClass('passive');
case 1 :
$('span#step3').removeClass('active').addClass('passive');
$('span#step1').removeClass('passive').addClass('active');
break;
case 2 :
$('span#step1').removeClass('active').addClass('passive');
$('span#step2').removeClass('passive').addClass('active');
break;
case 3 :
$('span#step2').removeClass('active').addClass('passive');
$('span#step3').removeClass('passive').addClass('active');
break;
/*default :
$('span#step1').removeClass('passive').addClass('active');
break; */
}
});
/*
Available data:
isBackNavigation - boolean
settings - options object containing the options set for the wizard
activatedSteps - list of activated steps (visited steps)
isLastStep - boolean specifying whether the current step is a submit step
isFirstStep - boolean
previousStep - the id of the previously visited step
currentStep - the id of the current step
backButton
nextButton
steps - the steps of the wizard
firstStep - the id of the first step
*/
})
$("input.#countryPrefix").mask("+999");
$("input#phoneNumber").mask("99.99.99");
$("input#areaCode").mask("(999)");
$("input.zipcode").mask("99999");
////**********//////
$("#demoForm").formwizard({
formPluginEnabled: true,
validationEnabled: true,
focusFirstInput : true,
formOptions :{
success: function(data){$("#status").fadeTo(500,1,function(){ $(this).html("You are now registered!").fadeTo(5000, 0); })},
beforeSubmit: function(data){$("#data").html("data sent to the server: " + $.param(data));},
dataType: 'register(1).php',
resetForm: true
},
validationOptions : {
rules: {
username: {
required: true,
minlength: 3,
maxlength:10,
regex: /^[a-zA-Z0-9._-]+$/i,
remote: {
url: "user_unique.php",
type: "post",
data: {
username: function() {
return $("#username").val();
}
}
}
},
password: {
required: true,
minlength: 4
},
confirm_password: {
required: true,
minlength: 4,
equalTo: "#password"
},
email: {
required: true,
email: true,
remote: {
url: "email_unique.php",
type: "post",
data: {
email: function() {
return $("#email").val();
}
}
}
},
country: {
required: true
},
//phoneNumber: { required: true, regex : /^[\d\s]+$/, minlength: 10 },
pic: { accept: "(jpe?g|gif|png)" },
terms: "required",
firstname : {regex: /^[a-zA-Z0-9._-]+$/i},
surname : {regex: /^[a-zA-Z0-9._-]+$/i},
},
messages: {
username: {
required: "Please enter a username",
maxlength:"max length 10 letters",
minlength: "Your username must consist of at least 3 characters",
regex: "No special caracteres are allowed",
remote: jQuery.format("{0} is already in use")
},
password: {
required: "Please provide a password",
minlength: "Your password must be at least 4 characters long"
},
confirm_password: {
required: "Please provide a confirm password",
minlength: "Your password must be at least 4 characters long",
equalTo: "Please enter the same password as above"
},
country: "Please specify your country",
email: {
required: "Please specify your email",
email: "Correct format is name@domain.com",
remote: jQuery.format("{0} is already in use")
},
firstname: {regex: "No special caracteres are allowed"},
surname: {regex: "No special caracteres are allowed"},
pic : jQuery.format("Only {0} extention are allowed")
}
}
});
/***********************/
});
</script>
</body>
</html> |
Partager