1,676   7 insert database



Pennapa


พลังงานการช่วยเหลือ
( Level 1 )


คะแนนขอบคุณจากสมาชิก
( 0 )


ตอบกระทู้ ( 6 )
เขียนบทความ ( 0 )

//หน้า insert_account.php

Code (PHP)

<?php

require 'connect_mysqli.php';


$email = isset($_POST['email']) ? trim($_POST['email']) : "";

$sqli = "select * from usertable where Login ='{$email}' ";

$result = $mysqli->query($sqli);
if(mysqli_num_rows($result)>0)
{


/* echo 'Please enter a new duplicate emails',"<br><br>"; */
echo "<script>alert('Please enter a new duplicate emails');window.location='index.php';</script>";
exit(0);
}




$sqli = " insert into usertable (Login, Password)
values
(
'{$mysqli->escape_string($_POST['email'])}'
, '{$mysqli->escape_string($_POST['inputPassword'])}'

);
";

$result = $mysqli->query($sqli);



if($result){


echo "<script>alert('successful');window.location='continue.php';</script>";


}else{

echo 'unsuccessful',"<br><br>";
echo '<a href="index.php">Try Again</a>';
exit(0);

}


?>




----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//หน้า madallogin.php

<meta charset="UTF-8">
<title>Login to Everdwell</title>


<link rel="stylesheet" href="bootstrap-3.3.4/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet"
href="bootstrap-3.3.4/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="bootstrap-3.3.4/js/bootstrap.min.js"></script>
<script src="bootstrap-3.3.4/js/validator.js"></script>



<link
href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css"
rel="stylesheet">

<div id="login-overlay" class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">?</span><span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">Login to site.com</h4>
</div>



<div class="modal-body">
<div class="row">
<div class="col-xs-6">
<div class="well">
<form data-toggle="validator" role="form" action="" method="post"
id="login">
<div class="form-group">
<label for="inputName" class="control-label">Email</label> <input
type="email" class="form-control" id="mail" name="mail"
placeholder="Enter Email" required>
</div>


<div class="form-group">
<label for="inputName" class="control-label">Password</label> <input
type="password" class="form-control" id="pass" name="pass"
placeholder="Enter Password" required>
</div>


<div id="loginErrorMsg" class="alert alert-error hide">Wrong
username og password</div>
<div class="checkbox">
<label> <input type="checkbox" name="remember" id="remember">
Remember login
</label>
<p class="help-block">(if this is a private computer)</p>
</div>
<button type="submit" class="btn btn-primary btn-block">Login</button>
<a href="/forgot/" class="btn btn-default btn-block">Forgot
Password</a>
</form>
</div>
</div>




<div class="col-xs-6">
<form data-toggle="validator" role="form" id="register" name="register"
action="insert_account.php" method="post">
<div class="form-group">
<label for="inputName" class="control-label">Email</label> <input
type="email" class="form-control" id="email" name="email"
placeholder="Enter Email" required>
</div>


<div class="form-group">
<label for="inputPassword" class="control-label">Password</label>
<input type="password" data-minlength="6" class="form-control"
id="inputPassword" name="inputPassword" placeholder="Password"
required> <span class="help-block">Minimum of 6 characters</span>
</div>



<div class="form-group ">
<label for="inputPassword" class="control-label">Confirm
Password</label> <input type="password" class="form-control"
id="inputPasswordConfirm" name="inputPasswordConfirm"
data-match="#inputPassword"
data-match-error="Whoops, these don't match"
placeholder="Confirm" required>
<div class="help-block with-errors"></div>
</div>



<div id="loginErrorMsg" class="alert alert-error hide">Wrong
username og password</div>
<div class="checkbox">
<p>&nbsp;</p>
</div>
<button type="submit" class="btn btn-primary btn-block" id="btnSubmit">Create My
Account</button>

</div>


</form>

</div>
</div>
</div>
</div>



--------------------------------------------------------------------------------------------------------------------------------------------------------------------
https://drive.google.com/file/d/0Bz0wpJT7XoWscUZ6VTVEblN3OU0/view?usp=sharing
ความคิดเห็นที่ 1
อ้างอิงความเห็น


bamossza


พลังงานการช่วยเหลือ
( Level 3 )


คะแนนขอบคุณจากสมาชิก
( 16 )


ตอบกระทู้ ( 112 )
เขียนบทความ ( 28 )

ลองทำตามคำแนะนำดูนะครับ

หน้า madallogin.php

เพิ่มโค้ดนี้ก่อน tag [/head]

<script>
document.getElementById("checkEmailSame").style.visibility = "visible";
</script>

โค้ดเดิม

<div class="form-group">
 <label for="inputName" class="control-label">Email</label>
 <input type="email" class="form-control" id="email" name="email" placeholder="Enter Email" required>
</div>

ลองเพิ่มเติมเป็นแบบนี้ครับ

<div class="form-group">
<label for="inputName" class="control-label">Email</label>
<input type="email" class="form-control" id="email" name="email" placeholder="Enter Email" required>
<span id="checkEmailSame" style="color:red;">อีเมล์ซ้ำ กรุณากรอกใหม่</span>
</div>

หน้า insert_account.php

จากโค้ดตรงนี้

echo "<script>alert('Please enter a new duplicate emails');window.location='index.php';</script>";
exit(0);

แก้เป็น

?>
<script>
document.getElementById("checkEmailSame").style.visibility = "hidden";
</script>
<?php


ลองทำตามดูก่อนนะครับ ว่าทำได้ไหมcool
ความคิดเห็นที่ 2
อ้างอิงความเห็น


Pennapa


พลังงานการช่วยเหลือ
( Level 1 )


คะแนนขอบคุณจากสมาชิก
( 0 )


ตอบกระทู้ ( 6 )
เขียนบทความ ( 0 )

ขอบคุณค่ะ coolcool
ความคิดเห็นที่ 3
อ้างอิงความเห็น


Pennapa


พลังงานการช่วยเหลือ
( Level 1 )


คะแนนขอบคุณจากสมาชิก
( 0 )


ตอบกระทู้ ( 6 )
เขียนบทความ ( 0 )

พี่มอสคะ มันไม่เข้า javasclip ค่ะพี่มันเข้าที่ span เลยคือตอนที่ยังไม่ได้กรอกข้อมูลก็มีข้อความแจ้งเตือนค่ะพี่
ความคิดเห็นที่ 4
อ้างอิงความเห็น


bamossza


พลังงานการช่วยเหลือ
( Level 3 )


คะแนนขอบคุณจากสมาชิก
( 16 )


ตอบกระทู้ ( 112 )
เขียนบทความ ( 28 )

เอางี้ครับ ลองเปลี่ยน Jquery ครับ ง่ายกว่า
ตรงนี้
<script>
document.getElementById("checkEmailSame").style.visibility = "visible";
</script>

เปลี่ยนเป็น
<script>
$(function(){
 $("#checkEmailSame").show();
});
</script>


ส่วนตรง php
?>
<script>
document.getElementById("checkEmailSame").style.visibility = "hidden";
</script>
<?php

เปลี่ยนเป็น
?>
<script>
$(function(){
$("#checkEmailSame").hide();
});
</script>
<?php


ลองดูครับ
ความคิดเห็นที่ 5
อ้างอิงความเห็น


Pennapa


พลังงานการช่วยเหลือ
( Level 1 )


คะแนนขอบคุณจากสมาชิก
( 0 )


ตอบกระทู้ ( 6 )
เขียนบทความ ( 0 )

ได้แล้วค่ะพี่ laughing
ความคิดเห็นที่ 6
อ้างอิงความเห็น


bamossza


พลังงานการช่วยเหลือ
( Level 3 )


คะแนนขอบคุณจากสมาชิก
( 16 )


ตอบกระทู้ ( 112 )
เขียนบทความ ( 28 )

coolเยี่ยมมากครับ

แสดงความเห็น

อัพโหลดรูปภาพ..คลิก *** เพื่อความปลอดภัยในด้านสิทธิ ไม่อนุญาติให้นำลิ้งรูปภาพจากที่อื่นมาแปะ ถ้าพบเจอ ลบกระทู้ ทันที ***

Back to Top