Jump to content
php.lv forumi

reģistrēšanās ar nelielu jquery


ziedinjsh

Recommended Posts

Sveiki!

 

<div id='register'>
<div class='reg'>


<div class='i-ok' style='display:none;'>Reģistrācija ir paveikta! Lai ielogotos spied <a href='index.php?p=login'>šeit</a></div>
<div class='i-error' style='display:none;'>Kāds no laiuciņiem ir palicis neaizpildīts!</div>
<form method='post' id='reg' action='process/register_process.php'>
<h3>Vārds</h3>
<input type='text' name='firstname' id='firstname' class='input'>
<h3>Uzvārds</h3>
<input type='text' name='lastname' id='lastname' class='input'>
<h3>Lietotājvārds</h3>
<input type='text' name='username' id='username' class='input'>
<h3>e-pasts</h3>
<input type='text' name='email' id='email' class='input'>
<h3>Dzimšanas datums</h3>
<select name='day' class='day' id='day'>
<?php foreach($days as $day){echo "<option value='".$day."'>".$day."</option>";}?>
</select>
<select name='month' class='month' id='month'>
<?php foreach($month as $monthname){echo "<option value='".$monthname."'>".$monthname."</option>";}?>
</select>
<select name='year' class='year' id='year'>
<?php foreach($years as $year){echo "<option value='".$year."'>".$year."</option>";}?>
</select>
<h3>Dzimums</h3>
<div class='genere'>Vīrietis <input type='radio' name='genere' value='male'> Sieviete <input type='radio' name='genere' value='female'></div>
<h3>Parole</h3>
<input type='password' name='password' id='password' class='input'>
<h3>Atkārto paroli</h3>
<input type='password' name='password2' id='password2' class='input'>
<p><input type='submit' value='Reģstrēties' id='adduser' class='button'></p>
</form>

</div>

	<div class='info'>
	Visi lauciņi ir jāaizpilda obligāti!<br>
	Ja netiks aizpildīti visi lauiciņi, reģistrācija netiks veikta!
	</div>
		<div class='fix'></div>
</div>

 

$statuss = "ok";

$firstname = mysql_real_escape_string($_POST['firstname']);
$lastname = mysql_real_escape_string($_POST['lastname']);
$username = mysql_real_escape_string($_POST['username']);
$email = mysql_real_escape_string($_POST['email']);
$genere = mysql_real_escape_string($_POST['genere']);

$day = mysql_real_escape_string($_POST['day']);
$month = mysql_real_escape_string($_POST['month']);
$year = mysql_real_escape_string($_POST['year']);

$password = mysql_real_escape_string($_POST['password']);
$password2 = mysql_real_escape_string($_POST['password2']);


$birthday = $day.".".$month.".".$year;
$date = date("d.m.y");


if(empty($firstname) || empty($lastname) || empty($username) || empty($email) || empty($genere) || empty($password) || empty($password2)){
$error = "Kads lauciņš ir tukš!";
	$statuss = "error";
}

if(empty($day) || empty($month) || empty($year)){
 $error = "Tev jānorāda savs dzimšanas datums!";
	$statuss = "error";
}

if(!(preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $email))){
$error = "Lūdzu ievadi korektu e-pastu!";
	$statuss = "error";
}

$check = mysql_query("SELECT * FROM users WHERE email='$email'");
if (mysql_num_rows($check)>=1){
$error = "Šāds e-pasts jau ir reģistrēts";
	$statuss = "error";
}

if($password!=$password2){
$error = "Paroles nesakrīt";
	$statuss = "error";
}

if($statuss<>"ok"){
echo $error;
}else{

echo "Reģistrācija veiksmīga!<br>";

echo $firstname."<br>";
echo $lastname."<br>";
echo $username."<br>";
echo $email."<br>";
echo $genere."<br>";
echo $birthday."<br>";
echo $password."<br>";

}

 

viss strādā! Bet ir vēlme tāda, kad nospiež pogu reģistrēties, kļūdu paziņojumu vai paziņojumu par veiksmīgu reģistrēšanos parāda bez lapas pārlādēšanas! tas sanāk, ievada datus bez lapas parlādēšanas un bez apas pārlādēšanas nolasa rezūltātu no register_progress.php

 

Paldies jau ieprieks! :)

Link to comment
Share on other sites

mby nostrādā. netestēju.

 

<script type="text/javascript" language="javascript">
$('#register').submit(function() {
 var first = document.getElementbyId('firstname').value;
 if(first == '')
 {
     alert('Ievadi vārdu!');
     return false; 
 }
 else
 {
    $.ajax({
    type: "POST",
    url: "register_process.php",
    data: ({first : first}),
    success: function(msg)
    {
    alert("Reģistrācijas veiksmīga!");
    }
    });
 }
});
</script>

Link to comment
Share on other sites

variants ir īstais.. sarakstīju pārējos

$(function() {
$("#adduser").click(function(){
$.post("process/register_process.php", {
firstname:document.getElementById("firstname").value,
lastname:document.getElementById("lastname").value,
username:document.getElementById("username").value,
email:document.getElementById("email").value,
genere:document.getElementById("genere").value,
password:document.getElementById("password").value,
password2:document.getElementById("password2").value,
day:document.getElementById("day").value,
month:document.getElementById("month").value,
year:document.getElementById("year").value,

}, function(data){
document.getElementById("result").innerHTML = data;
});
});
});

 

izveidoju div ar id result, diemžel nekas nenotiek! :|

Link to comment
Share on other sites

Nav testēts, bet in general:

 

$(document).ready(function() {
$('#reg').submit(function() {
	$.ajax({
		type: "POST",
		url: $('#reg').attr('action'),
		data: $('#reg').serialize(),
		success: function(data) {
			$('#register').html(data);
		}
	});
	return false;
});
});

 

#register vietā var ielikt speciālu lauku atgrieztajam statusa mesidžam, kaut kur virs formas, lai pati forma nepazūd.

 

nice1 Tev iesaka pilnīgas muļķības.

Edited by mad182
Link to comment
Share on other sites

  • 4 months later...

Pamēģini vēl, varbūt ar nākošo reizi izdosies.

.animate( properties [, duration] [, easing] [, complete] )

 

properties A map of CSS properties that the animation will move toward.

duration A string or number determining how long the animation will run.

easing A string indicating which easing function to use for the transition.

complete A function to call once the animation is complete.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...